B. Equations of Mathematical Magic

Posted mch5201314

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}

以上是关于B. Equations of Mathematical Magic的主要内容,如果未能解决你的问题,请参考以下文章

LC 990. Satisfiability of Equality Equations

Various formulations of Maxwell equations

Satisfiability of Equality Equations - LeetCode

B. Divisiblity of Differences

B. Divisors of Two Integers

Round 310(Div.1) B. Case of Fugitive