ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1079. Maximum

What is a wrong?
Posted by Emilbek 24 May 2008 17:38
#include<iostream.h>

void main()
{
int a[10000],max[10];
int i,j,num,n;
for(i=0;i<10;i++)
{
cin>>n;
if(n==0)
break;
max[i]=0;
for(j=0;j<=n;j++)
{
if(j==0)
a[j]=0;
else
if(j==1)
a[j]=1;
else
if(j%2==0)
a[j]=a[j/2];
else
a[j]=a[(j-1)/2]+a[(j-1)/2+1];
if(a[j]>max[i])
max[i]=a[j];
}
}
num=i;
for(i=0;i<num;i++)
cout<<max[i]<<endl;
}
Re: What is a wrong?
Posted by Howard Liu 26 May 2008 00:24
N goes up to 100000, not merely 10000.