for _ in range(int(input())):
d=int(input())
if d==0:
print("Y",0/1,0/1)
continue
if d<4:
print("N")
continue
tmp=(d*d-4*d)**0.5
print("Y",(d+tmp)/2,(d-tmp)/2)
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
#include <limits>
using namespace std;
long double bs(long double s,long double e,long long d){
if(s<=e){
long double mid=s+(e-s)/2;
long double ans =mid*(d-mid);
if(abs(mid*(d-mid))<=0.000001) return mid;
else if(ans>d ) return bs(mid+0.000000001,e,d);
else return bs(s,mid-0.000000001,d);
}
return s;
}
int main() {
int t;
cin>>t;
while(t--){
long long d;
cin>>d;
long double a;
a =bs(0,1000000000,d);
cout.precision(10);
if(d==0){
cout<<fixed<<"Y"<<" "<<0.000000<<" "<<0.000000<<endl;
}
else if(d==1){
cout<<"N"<<endl;
}
else if(d==4){
cout<<fixed<<"Y"<<" "<<2.000000<<" "<<2.000000<<endl;
}
else if(abs((a*(d-a))-d)<=0.000001){
cout<<fixed<<"Y"<<" "<<a<<" "<<d-a<<endl;
}else{
cout<<"N"<<endl;
}
}
return 0;
}
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |
Char Sum | Two Strings |
Anagrams | Prime Number |
Lexical Sorting Reloaded | 1514A - Perfectly Imperfect Array |
580A- Kefa and First Steps | 1472B- Fair Division |
996A - Hit the Lottery | MSNSADM1 Football |
MATCHES Playing with Matches | HRDSEQ Hard Sequence |
DRCHEF Doctor Chef | 559. Maximum Depth of N-ary Tree |
821. Shortest Distance to a Character | 1441. Build an Array With Stack Operations |
1356. Sort Integers by The Number of 1 Bits | 922. Sort Array By Parity II |