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 I've CRASH (ACCESS_VIOLATION) (C++) ?
Posted by sikee8 11 Apr 2002 19:39
And I also have ACCESS_VIOLATION in some other problem (1184,1049).

My program:

#include <iostream.h>

int main ()
{
    int a[100001];
    a[0]=0; a[1]=1;
    long i = 1;
    while (i++<100000)
    {
        a[i] = a[i++/2];
        a[i] = a[i/2] + a[i/2+1];
    }
    for (i=2; i<=100000; i++) if (a[i-1]>a[i]) a[i]=a[i-1];
    while (i)
    {
        cin >> i;
        if (i)  cout << a[i] << "\n";
    }
    return 0;
}