zoukankan      html  css  js  c++  java
  • 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
    ");
            else
            {
                double ans = (a+sqrt(a*a-4*a))/2.0;
                printf("Y %.9lf %.9lf
    ",ans,a-ans);
            }
        }
        return 0;
    }
  • 相关阅读:
    vue.js打包后,接口安全问题
    PHP开发api接口安全验证
    DOS命令操作 规格严格
    IIS 规格严格
    Swing语法高亮 规格严格
    Jetty 规格严格
    How to avoid “Illegal type in constant pool 规格严格
    数据库表产生类 规格严格
    利用Java编写简单IIS日志清理工具 规格严格
    语法高亮 规格严格
  • 原文地址:https://www.cnblogs.com/Romantic-Chopin/p/12451259.html
Copyright © 2011-2022 走看看