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 |
这道题我用公式做的,怎么会错#include<stdio.h> #include<math.h> int c,n,m,i,nCase; long long a[4001]; int main() { a[1] = 0; for(i=2; i<=4000; i++) { a[i] = a[i-1] + i/2; // printf("%d:%d ",i,a[i]); } // printf("%d\n",a[2000]); scanf("%d",&c); for(nCase=1; nCase<=c; nCase++) { scanf("%d%d",&n,&m); if(n==1) { printf("Case %d: n = %d, m = %d, # lists = %d\n",nCase,n,m,m); continue; } if(m<pow(2,n-1)) { printf("Case %d: n = %d, m = %d, # lists = %d\n",nCase,n,m,0); } else { printf("Case %d: n = %d, m = %d, # lists = %d\n",nCase,n,m,a[m+2-int(pow(2,n-1))]); } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator