fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ull unsigned long long
  4. #define all(x) x.begin(), x.end()
  5. #define endl '\n'
  6. using namespace std;
  7. //vector<vector<int>> arr(n + 1, vector<int>(m + 1));
  8. bool check_bit(long long n,long long i) {
  9. return (n>>i)&1;
  10. }
  11. int count_ones(ll n) {
  12. return __builtin_popcountll(n);
  13. }
  14. int getBit(int num,int pos)
  15. {
  16. num=num>>pos;
  17. return num&1;
  18. }
  19. int gcd(int a, int b) {
  20. if (b == 0)
  21. return a;
  22. return gcd(b, a % b);
  23. }
  24. bool isvowel(char c) {
  25. return (c == 'a' || c == 'e' || c == 'i' || c == 'o'|| c == 'u');
  26. }
  27. bool is_equal(vector<int>v,int x) {
  28. for(int i=0;i<v.size();i++) {
  29. if(v[i]!=x) return false;
  30. }
  31. return true;
  32. }
  33. void solve() {
  34. ios::sync_with_stdio(false);
  35. cin.tie(nullptr);
  36. //freopen("input.txt","r",stdin);
  37. //freopen("output.txt","w",stdout);
  38. int t=1;
  39. cin>>t;
  40. while(t--) {
  41. double x;
  42. cin>>x;
  43. double l=0,r=1e3+1;
  44. double iter=600;
  45. bool flag=false;
  46. while(l<=r&&iter--) {
  47. double mid=(l+r)/2;
  48. double x2=abs(x-mid);
  49. if ((x2+mid==x)&&(ceil(x2*mid)==x)) {
  50. if (mid<x2) {
  51. cout<<fixed<<setprecision(9)<<"Y"<<" "<<x2<<" "<<mid<<endl;
  52. }
  53. else {
  54. cout<<fixed<<setprecision(9)<<"Y"<<" "<<mid<<" "<<x2<<endl;
  55. }
  56. flag=true;
  57. break;
  58. }
  59. if ((mid+x2)>x||ceil(mid*x2)>x) {
  60. r=mid;
  61. }
  62. else {
  63. l=mid;
  64. }
  65.  
  66. }
  67. if (!flag) {
  68. cout<<"N\n";
  69. }
  70. }
  71.  
  72. }
  73. int main() {
  74. solve();
  75. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
N