您的位置:首页 > 其它

玲珑杯”ACM比赛 Round #5 --2的幂次方

2016-11-27 10:28 429 查看
1064 - I am Two

Time Limit:1s Memory Limit:64MByte

Submissions:522Solved:205

DESCRIPTION

Check whether an integer n is a power of 2.

INPUT

First line contains a single integer T (T<=20) which denotes the number of test cases. For each test case, there is an 32-bit integer N .

OUTPUT

For each case, output the "Yes" or "No" in a single line.

SAMPLE INPUT

3138

SAMPLE OUTPUT

YesNoYes

SOLUTION

玲珑杯”ACM比赛 Round #5

code:

#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(n>0&&(n&(n-1))==0)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: