Posted on 2008-03-26 20:57
superman 阅读(313)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1088 C++ 00:03.46 836K */
2 #include <iostream>
3
4 using namespace std;
5
6 int main()
7 {
8 int n;
9 while((cin >> n) && n)
10 {
11 int k = 2;
12 while(1)
13 {
14 int now = 0, left = n - 2;
15 bool x[200] = {1}, flag = 0;
16 while(1)
17 {
18 int i = 0;
19 while(i < k)
20 {
21 if(x[(now + 1) % n] == 0)
22 i++;
23 now = (now + 1) % n;
24 }
25 left--;
26 x[now] = 1;
27 if(now == 1)
28 break;
29 if(left == 0)
30 {
31 cout << k << endl;
32 flag = 1;
33 break;
34 }
35 }
36 if(flag)
37 break;
38 k++;
39 }
40 }
41
42 return 0;
43 }
44