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

Getting WA on first test even after doing binary search
Posted by viktor.fonic 13 Mar 2013 19:03
I tried everything:
1. Reading long long and then casting as needed to long double
2. Reading and doing operations with long double
3. Searching root with binary search

#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

int main()
{
    long double a;
    vector<long double> v;
    while (scanf("%lf", &a) != EOF) {
        v.push_back(a);
    }
    reverse(v.begin(), v.end());

    for (vector<long double>::iterator it = v.begin(); it != v.end(); ++it) {
        printf("%.4lf\n", sqrt(*it));
    }
    return 0;
}