B. Equations of Mathematical Magic

思路

打表找规律,发现结果是,2的(a二进制位为1总数)次方

代码

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t,a;
	//freopen("in.txt","r",stdin);
	cin>>t;
	while(t--){
		cin>>a;
		ll cnt=0;
		while(a){
			if(a&1) cnt++;
			a>>=1;
		} 
		cout<<(1ll<<cnt)<<endl;
	} 
	return 0;
}
posted @ 2018-10-15 18:12  ChunhaoMo  阅读(109)  评论(0编辑  收藏  举报