PKU 3327 Candy Distribution

很搞笑地过了这道题.测试每个数据,发现2的n次方的结果都是YES.
所以打了个表.发现AC了.不过不知道为什么,希望高人指点.
#include<iostream.h> long s[40]={2,4,8,16,32,64,128,256,512,1024, 2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576, 2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824}; void main() { int n; while(cin>>n) { int i; int t=0; for(i=0;i<30;i++) if(n==s[i]){t=1;break;} if(t)cout<<"YES"<<endl; else cout<<"NO"<<endl; } }

你可能感兴趣的:(测试)