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, please?
Posted by Sergio Alvarez 27 Apr 2008 03:30
This code seems to solve the problem on my computer, but it I got WA on test#3! I've been trying for some hours to improve it. But I think I've already tried everything I know (which is certainly not too much!) Please, can you tell me what's wrong here?

#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
using namespace std;
int main()
{
 const int size = 128000;
 int counter=0, max;
 double x;
 double* array = new double[size];
 double* ptr = array;

 cout.setf(ios::fixed);
 cout.setf(ios::showpoint);
 cout.precision(4);

 while(1)
 {
  cin>>x;
  if(cin.eof())break;

  counter++;
 (*ptr)=sqrt(x);

  if(counter < size)
   ptr++;
 }

 if(counter < size)
  ptr--;

 max = counter;

 for(counter=max;counter > 0;counter--)
 {
  cout<<*ptr<<endl;
  ptr--;
 }

 return 0;
}