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

why wrong answer(3)? c++
Posted by Dima Puz 2 Apr 2019 21:28
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
     long double a;
     vector< long double> mass;

    while (!cin.eof())
    {
        cin >> a;
            mass.push_back(a);
    }

    mass.erase(mass.end()-1);
    for (int i = 0; i < mass.size(); i++)
    {
        printf("%.4Lf",sqrt(mass[mass.size() -1- i]));
        printf("\n");
    }
    return 0;
}

Edited by author 02.04.2019 21:28

Edited by author 02.04.2019 21:49
Re: why wrong answer(3)? c++
Posted by Thrashans 17 Apr 2019 08:02
Use sqrtl.
Re: why wrong answer(3)? c++
Posted by Thrashans 17 Apr 2019 08:09
Change

while (!cin.eof()){
    cin >> a;
    mass.push_back(a);
}
mass.erase(mass.end()-1);

To

while (cin >> a)
{
    mass.push_back(a);
}