1. 程式人生 > >Educational Codeforces Round 54 (Rated for Div. 2) C. Meme Problem

Educational Codeforces Round 54 (Rated for Div. 2) C. Meme Problem

很簡單的一元二次方程,用高中學的公式求解就好啦。 

大晚上打比賽真刺激!!!嘿嘿嘿

C. Meme Problem

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Try guessing the statement from this picture:

You are given a non-negative integer dd. You have to find two non-negative real numbers aa and bb such that a+b=da+b=d and a⋅b=da⋅b=d.

Input

The first line contains tt (1≤t≤1031≤t≤103) — the number of test cases.

Each test case contains one integer dd (0≤d≤103)(0≤d≤103).

Output

For each test print one line.

If there is an answer for the ii-th test, print "Y", and then the numbers aa and bb.

If there is no answer for the ii-th test, print "N".

Your answer will be considered correct if |(a+b)−a⋅b|≤10−6|(a+b)−a⋅b|≤10−6 and |(a+b)−d|≤10−6|(a+b)−d|≤10−6.

Example

input

Copy

7
69
0
1
4
5
999
1000

output

Copy

Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main()
{
    int n,m,j,k,i,T;
    double a;
    cin>>T;
    while (T--)
    {
        cin>>a;
        if (a*a-4*a<0)
            printf("N\n");
        else
        {
            double ans = (a+sqrt(a*a-4*a))/2.0;
            printf("Y %.9lf %.9lf\n",ans,a-ans);
        }
    }
    return 0;
}