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 |
所有数据都过了非要说wa,你狠老子不做了#include<stdio.h> #include<string.h> int main() { int n, i, j, k, len, m[200], cnt, cph[200], itmp; char msg[200], mtmp[200]; bool mk[200]; while (scanf_s("%d", &n) && n) { for (i = 0; i < n; i++) scanf_s("%d", cph + i); memset(mk, 0, sizeof(mk)); memset(m, 0, sizeof(m)); for (i = 0; i < n; i++) if (mk[i] == false) { mk[i] = true; j = i; cnt = 1; while (cph[j] - 1 != i) { cnt++; mk[cph[j] - 1] = 1; j = cph[j] - 1; } j = i; do { m[j] = cnt; j = cph[j] - 1; } while (j != i); } while (scanf_s("%d", &k) && k) { getchar(); gets_s(msg); len = strlen(msg); for (i = 0; i < n - len; i++) msg[len + i] = ' '; msg[n] = '\0'; for (i = 0; i < n; i++) { itmp = i; for (j = 0; j < k%m[i]; j++) itmp = cph[itmp] - 1; mtmp[itmp] = msg[i]; } mtmp[n] = '\0'; printf("%s\n", mtmp); } printf("\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator