标签:des style blog http color io os java ar
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1026 Accepted Submission(s):
280
1 #include<iostream> 2 #include<stdio.h> 3 #include<cstring> 4 #include<cstdlib> 5 using namespace std; 6 typedef __int64 LL; 7 8 const LL p = 1e6+3; 9 int a[66]; 10 LL cnm[1002][1002]; 11 LL hxl[66]; 12 13 void Init() 14 { 15 for(int i=1;i<=1000;i++) 16 { 17 cnm[i][i]= 1; 18 cnm[i][1]= i; 19 cnm[i][0]=1; 20 } 21 cnm[0][0]=1; 22 for(int i=2;i<=1000;i++) 23 { 24 for(int j=1;j<=i;j++) 25 { 26 if(i==j)cnm[i][j]=1; 27 else if(j==1) cnm[i][j]=i; 28 else cnm[i][j] = (cnm[i-1][j]+cnm[i-1][j-1])%p; 29 } 30 } 31 hxl[1]=1; 32 for(int i=2;i<=64;i++) 33 hxl[i]=(hxl[i-1]*2)%p; 34 } 35 int main() 36 { 37 Init(); 38 int n; 39 LL x; 40 while(scanf("%d",&n)>0) 41 { 42 if(n==1) 43 { 44 scanf("%I64d",&x); 45 printf("%I64d\n",x%p); 46 continue; 47 } 48 memset(a,0,sizeof(a)); 49 for(int i=1;i<=n;i++) 50 { 51 scanf("%I64d",&x); 52 int len = 0; 53 while(x) 54 { 55 ++len; 56 a[len] = a[len]+(x&1); 57 x=x>>1; 58 } 59 } 60 LL sum ; 61 for(int m=1;m<=n;m++) 62 { 63 sum = 0; 64 for(int j=1;j<=64;j++) 65 { 66 for(int i=1;i<=a[j]&&i<=m;i=i+2) 67 { 68 //if(cnm[n-a[j]][m-i]) 69 sum = (sum+(hxl[j]*(cnm[a[j]][i]*cnm[n-a[j]][m-i])%p)%p)%p; 70 } 71 } 72 printf("%I64d",sum); 73 if(m!=n) printf(" "); 74 else printf("\n"); 75 } 76 } 77 return 0; 78 }
标签:des style blog http color io os java ar
原文地址:http://www.cnblogs.com/tom987690183/p/3976541.html