Posted on 2008-04-25 20:44
superman 阅读(193)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1164 C++ 00:00.00 856K */
2 #include <string>
3 #include <iostream>
4
5 using namespace std;
6
7 int main()
8 {
9 string s;
10 while(true)
11 {
12 getline(cin, s);
13
14 if(s == "#")
15 break;
16
17 int n = 0;
18 for(int i = 0; i < s.size(); i++)
19 n = (n * 256 + int(s[i])) % 34943;
20
21 n = n * 256 % 34943;
22 n = n * 256 % 34943;
23 n = (34943 - n) % 34943;
24
25 int left = n >> 8;
26 int right = n & 255;
27
28 char c1, c2, c3, c4, m[] = "0123456789ABCDEF";
29
30 c2 = m[left % 16]; left /= 16;
31 c1 = m[left % 16]; left /= 16;
32 c4 = m[right % 16]; right /= 16;
33 c3 = m[right % 16]; right /= 16;
34
35 cout << c1 << c2 << ' ' << c3 << c4 << endl;
36 }
37
38 return 0;
39 }
40