标签:style blog http color os io for ar 数据
这道题巨坑啊,样例中以-1结束输入的,所以我就天真的以为测试数据也是以-1结束输入的
其实人家原文中说:
Input is terminated by a line containing a negative integer.
是以负数结束输入,囧rz!
我这种英语渣渣,怎么可能注意到这种错误
我还以为是算法的问题,就写了两份代码
1 //#define LOCAL 2 #include <cstdio> 3 4 int a[20000]; 5 6 int main(void) 7 { 8 #ifdef LOCAL 9 freopen("11636in.txt", "r", stdin); 10 #endif 11 12 int n, kase = 0, j = 2; 13 for(int i = 1; i <= 14; ++i) 14 { 15 while(j <= (1 << i)) 16 { 17 a[j++] = i; 18 if(j > 10000) break; 19 } 20 if(j > 10000) break; 21 } 22 while(scanf("%d", &n)) 23 { 24 if(n < 0) break; 25 printf("Case %d: %d\n", ++kase, a[n]); 26 } 27 return 0; 28 }
1 //#define LOCAL 2 #include <cstdio> 3 4 int main(void) 5 { 6 #ifdef LOCAL 7 freopen("11636in.txt", "r", stdin); 8 #endif 9 10 int n, kase = 0; 11 while(scanf("%d", &n) == 1) 12 { 13 if(n < 0) break; 14 --n; 15 int cnt = 0; 16 while(n) { n >>= 1; ++cnt; } 17 printf("Case %d: %d\n", ++kase, cnt); 18 } 19 return 0; 20 }
标签:style blog http color os io for ar 数据
原文地址:http://www.cnblogs.com/AOQNRMGYXLMV/p/3935606.html