1 /* 2 字符串处理:要求解码,然而二维数组开不下,可以直接输出 3 只要在余数的地方判断一下就行了,vector的效率不高 4 另外:感觉麻烦的地方应该纸上写写就清楚了 5 */ 6 #include7 #include 8 #include 9 #include 10 #include 11 #include 12 using namespace std;13 14 const int MAXM = 1e6 + 10;15 const int INF = 0x3f3f3f3f;16 char s[MAXM];17 char ans[MAXM];18 19 int main(void) //2015百度之星资格赛 1002 列变位法解密20 {21 int n, m, k, cas = 0;22 int T;23 scanf ("%d", &T); getchar ();24 while (T--)25 {26 gets (s);27 scanf ("%d", &m);28 int len = strlen (s);29 n = len / m;30 k = len % m;31 32 printf ("Case #%d:\n", ++cas);33 int i = 0, j, l = 0, cnt;34 while (i < len)35 {36 j = i; cnt = 0;37 while (j < len)38 {39 printf ("%c", s[j]); ++l;40 if (cnt < k) {j += (n + 1); ++cnt;}41 else j += n;42 if (l == len) break;43 }44 ++i; if (l == len) break;45 }46 47 puts (""); getchar ();48 }49 50 return 0;51 }52 53 54 /*55 456 15926374857 458 Hw doeetrrlloellc adoomm!,my e w59 760 Toodming is best61 1662 sokaisan63 164 */
1 /* 2 800多MS 3 */ 4 #include5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 using namespace std;12 13 const int MAXM = 1e5 + 10;14 const int INF = 0x3f3f3f3f;15 char s[MAXM];16 vector ss[MAXM];17 18 int main(void) //2015百度之星资格赛 1002 列变位法解密19 {20 int n, m, k, cas = 0;21 int T;22 scanf ("%d", &T); getchar ();23 while (T--)24 {25 gets (s);26 //getline (cin, s);27 scanf ("%d", &m);28 int len = strlen (s);29 n = len / m;30 k = len % m;31 32 for (int i=0; i<=len; ++i) ss[i].clear ();33 34 int l = 0; int t = k;35 for (int j=0; j 0) ss[n].push_back (s[l++]);43 t--;44 }45 46 printf ("Case #%d:\n", ++cas);47 for (int i=0; i