码迷,mamicode.com
首页 > 其他好文 > 详细

B. Equations of Mathematical Magic

时间:2018-10-15 20:40:13      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:std   stdin   sync   二进制   fine   ica   amp   gic   ons   

思路

打表找规律,发现结果是,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;
}

B. Equations of Mathematical Magic

标签:std   stdin   sync   二进制   fine   ica   amp   gic   ons   

原文地址:https://www.cnblogs.com/mch5201314/p/9792608.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!