Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
看看为什么wa,跟ac程序对拍都没问题#include<stdio.h> __int64 c[33]={0}; int binary(long n,int bin[33]) { int t[33]; int i; int L; L=0; while(n!=0) { t[L++]=n%2; n/=2; } for(i=0;i<L;i++) { bin[i]=t[L-i-1]; } return L; } __int64 Cmn(int m,int n) { __int64 count; int i; if(m==0||m<n) return 0; if(n==0) return 1; count=m; for(i=1;i<n;i++) { count=count*(m-i)/i; } count/=i; return count; } __int64 sub(long N) { int bin[33]; int one; int L; int i,j; int m,n; __int64 count; L=binary(N,bin); count=c[L]; one=0; for(i=0;i<L;i++) { if(bin[i]==1) one++; if(bin[i]==0) { m=L-i-1; n=L/2-one-1; if(n>=0) { for(j=0;j<=n;j++) { count-=Cmn(m,j); } } } } if(n>=0&&bin[L-1]==0)count--; return count; } int main() { long a,b; __int64 r; __int64 count; int i,j; for(i=2;i<32;i++) { count=0; for(j=0;j<i/2;j++) { count+=Cmn(i-1,j); } c[i]=c[i-1]+count; } while(scanf("%ld%ld",&a,&b)!=EOF) { r=sub(b)-sub(a-1); printf("%ld\n",r); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator