100114G

无耻的暴力

#include<iostream>
#include<cstdio>
using namespace std;
int n;
int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cin>>n;
    int l=500000000;
    for(int i=0;i<=l;i++)
    {
        if(((i*2)^i)==n)
        {
            cout<<i*2<<endl;
            return 0;
        }
        if(((i*2+1)^i)==n)
        {
            cout<<i*2+1<<endl;
            return 0;
        }
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}

 

posted @ 2016-10-27 22:35  19992147  阅读(98)  评论(0编辑  收藏  举报