链接

[http://codeforces.com/contest/1076/problem/C]

题意

a+b=d and a⋅b=d. 计算出a和b

分析

ab=a(d-a)=d

aa-ad+d=0; 先判断再直接求根公式

代码

#include<bits/stdc++.h>
using namespace std;
int main(){
int t,d;
cin>>t;
while(t--){
cin>>d;
if(d*d-4*d<0) cout<<"N\n";
else{
cout<<"Y\n";
double a=(d*1.0-sqrt(d*d-4*d))/2.0,b=(d*1.0+sqrt(d*d-4*d))/2.0;
printf("%.9f %.9f\n",a,b);
}
}
return 0;
}
05-04 08:23