Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为啥总是Re啊,上百练试下都AC了,这边还是Re……#include <iostream> #include <string> #include <memory.h> using namespace std; int a[201][201],b[201],c[201],n; string s; void f()//迭代n次 { for(int i=2;i<=n+1;i++) { for(int j=1;j<=n;j++) { a[i][j]=a[1][a[i-1][j]]; } } } void g()//算出每个数循环的长度 { for(int i=1;i<=n;i++) { for(int j=2;j<=n+1;j++) { if(a[j][i]==a[1][i]){b[i]=j-1;break;} } } } int main() { int times; char tempc; int temp; while(cin>>n&&n!=0) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(int i=1;i<=n;i++) { cin>>a[1][i]; } while(cin>>times&×!=0) { if(n==1){cin>>s;cout<<s<<endl;continue;} f();g(); memset(c,0,sizeof(int)*201); cin.get(); getline(cin,s); int len=s.length(); while(len<n) {s=s+" ";len++;} for(int j=1;j<=n;j++) { int z=times%b[j]; if(z==0) {c[j]=a[b[j]][j];} else { c[j]=a[z][j]; } } for(int p=0;p<=n-2;p++) { for(int q=p+1;q<=n-1;q++) { if(c[p+1]>c[q+1]) { temp=c[p+1];c[p+1]=c[q+1];c[q+1]=temp; tempc=s[p];s[p]=s[q];s[q]=tempc; } } } cout<<s<<endl; } cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator