Posted on 2008-03-12 21:27
superman 阅读(279)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1006 C++ 00:00.01 836K */
2 #include <stdio.h>
3 #include <string.h>
4 #include <iostream>
5
6 using namespace std;
7
8 int mod(int a, int b)
9 {
10 while(a < 0)
11 a += b;
12 return a % b;
13 }
14
15 int main()
16 {
17 //freopen("p1006.in", "r", stdin);
18
19 int k;
20 char s[100], c[100];
21 while(scanf("%d %s", &k, s) == 2)
22 {
23 int n = strlen(s);
24 for(int i = 0; i < n; i++)
25 {
26 switch(s[i])
27 {
28 case '_' : s[i] = 0; break;
29 case '.' : s[i] = 27; break;
30 default : s[i] = s[i] - 'a' + 1;
31 }
32 c[k * i % n] = (s[i] + i) % 28;
33 }
34
35 for(int i = 0; i < n; i++)
36 switch(c[i])
37 {
38 case 0 : c[i] = '_'; break;
39 case 27 : c[i] = '.'; break;
40 default : c[i] = 'a' + c[i] - 1;
41 }
42
43 for(int i = 0; i < n; i++)
44 cout << c[i];
45 cout << endl;
46 }
47
48 return 0;
49 }
50