codeforce 611B New Year and Old Property

暴力搞

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

long long a,b;
long long tmpa,tmpb;
long long num1[70],num2[70];
int tot1,tot2;


int main()
{
//    freopen("F:\\info.txt","w",stdout);
    scanf("%lld%lld",&a,&b);
    tmpa=a;
    tmpb=b;
    tot1=0;tot2=0;
    while(tmpa) num1[tot1++]=tmpa%2,tmpa=tmpa/2;
    while(tmpb) num2[tot2++]=tmpb%2,tmpb=tmpb/2;

    long long c=0;

    long long ans=0;

    for(int len=tot1;len<=tot2;len++)
    {
        for(int i=0;i<len-1;i++)
        {
            c=0;
            for(int j=0;j<len;j++)
            {
                if(i==j) continue;
                else c=c+(long long)pow(2.0,j);
            }
        //    printf("%lf\n",c);
            
            if(c-a>=0&&b-c>=0) ans++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

 

posted @ 2016-01-02 09:42  Fighting_Heart  阅读(172)  评论(0编辑  收藏  举报