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

Tried so many times, still failed. Hope help.
Posted by J.Liu 27 Aug 2013 09:15

#include <iostream>
#include <math.h>

using namespace std;
int main()
{
  double *n = new double[10000000];
  double buf;
  int index = 0;
  while(1)
  {
    cin >> buf;
    if(cin.eof())
    {
      break;
    }
    else
    {
      n[index++] = sqrt(buf);
    }
  }
  index--;
  cout.precision(4);
  while(index >= 0)
    cout << fixed << n[index--] << endl;
  delete [] n;
}
Re: Tried so many times, still failed. Hope help.
Posted by J.Liu 27 Aug 2013 09:26
// This one pass.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
  double *values = new double[131072];
  double buf;
  int index = 0;
  while(cin >> buf)
  {
    values[index++] = sqrt(buf);
  }
  index--;
  while (index >= 0)
    printf("%.4f\n", values[index--]);
  delete [] values;
}

Edited by author 27.08.2013 09:26

Edited by author 27.08.2013 09:26