当前位置:网站首页>[51nod p3216] Award [bit operation]

[51nod p3216] Award [bit operation]

2022-06-13 09:35:00 Ayane.

 Insert picture description here
 Insert picture description here
l i n k link link

analysis :

Medals are all 2 2 2 The power of So I just ask how many binary numbers there are for each number 1 1 1

CODE:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define reg register
using namespace std;
typedef long long ll;
int n,x; 
int main(){
    
	scanf("%d",&n);
	while(n--)
	{
    
		int ans=0;
		scanf("%d",&x);
		while(x)
		{
    
			ans+=(x&1);
			x>>=1;
		} 
		printf("%d\n",ans);
	}
	return 0;
}
原网站

版权声明
本文为[Ayane.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270530324382.html