0分求助

P1061 [NOIP2006 普及组] Jam 的计数法

@[墨石](/user/393601) ``` #include<bits/stdc++.h> using namespace std; int s,t,w,c; int a[30],cnt; inline void output() { for(int i=1;i<=w;i++) cout<<(char)('a'+a[i]-1); cout<<endl; } void dfs(int pos,int step) { if(pos==0)return; if(step==6)return; if(a[pos]<t&&a[pos]<a[pos+1]-1) { a[pos]++; for(int i=pos+1;i<=w;i++) a[i]=a[i-1]+1; output(); dfs(w,step+1); } else dfs(pos-1,step); } int main() { cin>>s>>t>>w; fflush(stdin); while((c=getchar())!=EOF) { int temp=c-'a'+1; if(temp>=1&&temp<=26)a[++cnt]=temp; } a[w+1]=0x7f; dfs(w,1); return 0; } ``` 不瞒你说,我是来挖坟的
by all___right @ 2023-07-25 06:46:21


|