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

Memory limit exceeded
Posted by Enoch 19 Aug 2014 00:09
#include <stack>
#include <cmath>
#include <iostream>

int main()
{
    unsigned long long int n;
    std::stack<unsigned long int> numbers;

    while (!std::cin.eof())
        numbers.push(n);
    while (!numbers.empty())
    {
        std::cout << sqrt( double( numbers.top() ) ) << " ";
        numbers.pop();
    }

    return 0;
}


Probably the stack this code builds is too large, but I can't see how to optimise it, given the sample numbers.
Re: Memory limit exceeded
Posted by ER 22 Aug 2014 13:53
I don't think your first while loop ever terminates.