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

If anyone can help me? Look at my program.
Posted by hhq21401 1 May 2004 13:26
//program 1079

#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: If anyone can help me? Look at my program.
Posted by Andrei Moga 1 May 2004 22:24
restriction for n is 100000 not 10000!
Re: If anyone can help me? Look at my program.
Posted by hhq21401 2 May 2004 07:46
Thank you.
I'm so careless.