poj 1665 && 1666

题目:http://poj.org/problem?id=1665

http://poj.org/problem?id=1666

1665 :读清题意,这个题目也就是几行代码。题目里给的那个 n 是转的圈数,而不是转速,注意单位间的换算

1666:纯粹的一个模拟,数据n开到了10000,具体多少好像题目没说

View Code
 1 const int N = 10000;
 2 int cand[N];
 3 int main()
 4 {
 5     int i,j;
 6     int n;
 7     while(~scanf("%d",&n))
 8     {
 9         if(n == 0) break;
10         _clr(cand,0);
11         for(i = 1; i <= n; i++)
12         scanf("%d",&cand[i]);
13         ll sum = 0;
14         while(1)
15         {
16             int flag = 0;
17             for(i = 1; i <= n; i++)
18             {
19                 if(cand[i] != cand[1]) {flag = 1;break;}
20             }
21             if(!flag) break;
22             int temp = cand[n];
23             cand[n] /= 2;
24             for(i = n - 1; i >= 1; i--)
25             {
26                 cand[i] /= 2;
27                 cand[i + 1] += (cand[i]);
28             }
29             cand[1] += (temp / 2);
30             sum ++;
31             for(i = 1; i <= n; i++)
32             if(cand[i] % 2) cand[i] ++;
33         }
34         printf("%I64d %d\n",sum,cand[1]);
35     }
36     return 0;
37 }

原文地址:https://www.cnblogs.com/fxh19911107/p/2764155.html