1 条题解

  • 0
    @ 2022-8-12 20:59:03

    二分答案

    /*****************************************
    Note  :
    ******************************************/
    #include <queue>
    #include <math.h>
    #include <stack>
    #include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    #include <string.h>
    #include <algorithm>
    #define LL long long
    #define IL inline
    const int N = 1e6+10;
    const int INF = 0x3f3f3f3f;
    using namespace std;
    IL int read()
    {
        char ch = getchar();
        int f = 1, num = 0;
        while(ch>'9'||ch<'0')
        {
            if(ch=='-') f = -1;
            ch=getchar();
        }
        while(ch>='0'&&ch<='9')
            num = num*10+ch-'0', ch = getchar();
        return num*f;
    }
    int t;
    double d;
    int main()
    {
    	t=read();
    	while(t--)
        {
            cin>>d;
            if((d/2)*(d/2)<d)
                puts("N");
            else
            {
                double l =0,r=d/2;
                while(r-l>=0.000001)
                {
                    double mid=(l+r)/2;
                    if(mid*(d-mid)-d>=0.00001)
                        r=mid;
                    else l=mid;
                }
                double ans=d-l;
                printf("Y %.2lf ",l);
                printf("%.2lf\n",ans);
            }
        }
    }
    
    • 1

    信息

    ID
    2317
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    递交数
    22
    已通过
    5
    上传者