|
|
back to boardWhy i have WA on the test 1?? all my outputs are right? what the ...? Posted by Shadow 29 Sep 2009 01:17 my code: #include "stdio.h" #include "iostream.h" #include "math.h" int main() { long a[100001],i; a[0]=0; a[1]=1; for(i=2;i<100001;i++) { if(i%2==0) { a[i]=a[i/2]; } else { a[i]=a[i/2]+a[i/2+1]; } } int t[10]; i=0; while(true) { cin>>t[i]; if(t[i]==0) break; i++; } i=0; long max; while(t[i]!=0) { for(int j=0;j<t[i]+1;j++) { if(a[j]>max) { max=a[j]; } } cout<<max<<"\n"; max=-1; i++; } return 0; } |
|
|