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

Why Crash? Can you help me?
Posted by hhq21401 1 May 2004 13:18
#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;
}