Codeforces Round #516 (Div. 2,B. Equations of Mathematical Magic(思维)

题目链接:http://codeforces.com/contest/1064/problem/B

#include<bits/stdc++.h>
using namespace std;

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define read(x,y) scanf("%d%d",&x,&y)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
const int  maxn =2e3+5;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x) if(y&1) t=t*x; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*
题目大意:求解方程解的个数,
不难发现,把这个数转换成二进制形式,
那么符合等式的解可以看到只要是二进制的1的集合的子集就符合要求,
然后如果在零处有任何1数,那么a^x就比a大了,这明显与等式不符合。


*/

ll cnt(ll x)
{
    ll tmp=0;
    while(x)
    {
        if(x%2==1) tmp++;
        x>>=1;
    }
    return tmp;
}

int main()
{
    int t;scanf("%d",&t);
    while(t--)
    {
        ll x;scanf("%lld",&x);
        ll ans=powmod(2LL,cnt(x));
        if(x==0) puts("1");
        else printf("%lld\n",ans);
    }
    return 0;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值