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;
}

 

转载于:https://www.cnblogs.com/Romantic-Chopin/p/10253035.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值