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 1001. Reverse Root

Please, tell me, why? ... :(
Posted by Anton Silin (YarSU) 12 Aug 2007 01:59
This code gives crash on 7 test, I don't know, why...

#include <iostream.h>
#include <stdio.h>
#include <math.h>
int i;
void main()
{
    double M[8000];
    double t;
    int n=0;
    while ( cin >> t )
    {
        M[n] = sqrt( t );
        n++;
    }

    for( int i=n-1; i>=0; i--)
    {
        printf("%.4f\n", M[i] ) ;
    }

}

Can you give any idea, why is it so?
Re: Please, tell me, why? ... :(
Posted by CHIDEMYAN SERGEY 12 Aug 2007 03:22
8000 don't enough.Put attention there:Размер входного потока не превышает 256 КБ.
If you write
double *M=new double[8000000](i.e.creating dynamic array)
instead of
double M[8000]
I'm think you will get AC.Good luck!

Edited by author 12.08.2007 03:29