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

Can anybody help me with WA#3
Posted by Yuriy_Dobryanskyy_PM_LNU 23 Mar 2007 03:26
this is my code and I can't see any mistakes here.....
#include <iostream>
using namespace std;
#include <cmath>
double a[33000];
int main()
{
    char c;
    __int64 N = 0,y;
    for(;;N++)
    {
        cin>>y;
        a[N] = sqrt(double(y));
        c = cin.peek();
        if(c == -1)break;
    }
    cout.precision(4);
    N--;
    for(;N>=0;N--)
        cout<<fixed<<a[N]<<endl;
    return 0;
}
Re: Can anybody help me with WA#3
Posted by Soul Reaver 23 Mar 2007 20:02


Edited by author 23.03.2007 20:02
Re: Can anybody help me with WA#3
Posted by Romko [Lviv NU] 23 Mar 2007 20:04
You should use
while(cin >> y){...}

instead of

for(;;N++)
{
cin>>y;
...}
And one more thing. Size of array should be very big, so use:

#pragma comment(linker, "/STACK:16777216")//!!
using namespace std;

double a[100000000];

Edited by author 23.03.2007 20:05