51nod 2512

看错题目!!啊啊啊,都说了不能有前导,我怎么这么想当然呢!!另外1也是2的幂次方

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
using namespace std;
#define maxn 1000000008
#define ll long long

int num[10];
char s[100];
int main(){
    scanf("%s",s);
    int len=strlen(s);
    rep(i,0,len){
        int x=s[i]-'0';
      //  cout<<x<<endl;
        num[x]++;
    }
    ll b=1;
    int flag=0;
    while(b<maxn){
        ll tp=b;
        int tmp[10];
        memset(tmp,0,sizeof(tmp));
        while(tp){
            int x=tp%10;
            tmp[x]++;
            tp/=10;
           // cout<<" <"<<x<<"> "<<endl;
        }
        int f=1;
        rep(i,0,10){
            if(num[i]!=tmp[i]){
                f=0;
                break;
            }
        }
        if(f)
        {
            flag=1;
            break;
        }
        b<<=1;
    }
    if(flag)
        cout<<"true"<<endl;
    else
        cout<<"false"<<endl;
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/pipitongkw1/p/10788205.html