cipher
来源:互联网 发布:java算法书籍推荐 编辑:程序博客网 时间:2024/05/22 05:04
http://icpc.njust.edu.cn/Problem/Local/1001/
//经分析,字符串x次变换后会与初始状态相同#include <cstdio>#include <iostream>#include <cstring>using namespace std;int arr[201];char s[201][201];bool compare(char s1[],char s2[],int n){ for(int i=0;i<n;i++) if(s1[i]!=s2[i]) return false; return true;}int main(){ int n; while(cin>>n) { if(!n) return 0; for(int i=0;i<n;i++) cin>>arr[i]; int k; while(cin>>k) { char str[201]; int ans=-1; if(!k) break; char ch; ch=getchar(); gets(str); for(int i=0;i<strlen(str);i++) s[0][i]=str[i]; for(int i=strlen(str);i<n;i++) s[0][i]=' '; //开始k次变换 for(int i=1;i<k+1;i++) { for(int j=0;j<n;j++) { int index; for(index=0;index<n;) { if(arr[index]==j+1) break; index++; } s[i][j]=s[i-1][index]; } if(compare(s[0],s[i],n))//说明周期为i { ans=k%i; break; } } if(ans==-1) ans=k; for(int i=0;i<n;i++) cout<<s[ans][i]; cout<<endl; } cout<<endl; }}
阅读全文
0 0
- Cipher
- Cipher
- Cipher
- cipher
- Cipher Code
- 1026 Cipher
- EVP cipher
- Playfair Cipher
- 加密---Cipher
- Cipher-----置换
- Cipher(P1026)
- Ancient Cipher
- Cipher Message
- uva1339Ancient Cipher
- POJ2159Ancient Cipher
- Cipher Message
- Cipher Lock
- Cipher Lock
- C语言入门——数字特征值
- hibernate查询list结果集结果都是一样
- s3c2440 ARM9 裸机驱动第一篇-GPIO驱动(C)
- [2017纪中11-3]机房比教室好多了 博弈+树型DP
- JAVA内存模型
- cipher
- Ubuntu安装Tomcat
- hiERROR: Value '0000-00-00' can not be represented as java.sql.Timestamp
- SQL分组查询
- java 集合遍历Iterator/foreach
- 下载并升级更新pip
- Spark 计算框架
- sizeof用于判断表达式的长度时的注意事项
- python在pycharm中代码格式化及快速注释