第一题还没看懂题意:等以后懂了再补吧。
列变位法解密
Accepts: 395
Submissions: 1308
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
有vector记录即可
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<cmath> #include<queue> #include<list> #include<vector> using namespace std; const int maxn=100010; char str[maxn]; vector<char>vec[maxn]; int main() { int t,i,j,k,test=1; scanf("%d",&t); while(t--){getchar(); gets(str); scanf("%d",&k); int len=strlen(str); int col=len/k;if(len%k)col++; for(i=0;i<col;++i)vec[i].clear(); int col1=col; int cnt=0,num=len%k; for(i=0;i<len;i+=col){ if(cnt>=num&&num){ col--;num=maxn; } for(j=i;j<i+col&&j<len;++j){ vec[j-i].push_back(str[j]); } cnt++; } printf("Case #%d:\n",test++); for(i=0;i<col1;++i){ for(j=0;j<vec[i].size();++j){ printf("%c",vec[i][j]); } } printf("\n"); } return 0; }
IP聚合
Accepts: 410
Submissions: 1037
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)