Codeforces 1076C. Meme Problem Solution

hints :(a-b)^2=(a+b)^2-4*a*b

Solve in  C++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE
///Islamic University,Bangladesh

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
    int d,i,n;
    double a,b,r;
    cin>>n;
    while(n--)
    {
        cin>>d;
        r=(d*d)-4*d;
        if(r<0)
        {
            cout<<"N"<<endl;
        }
        else
        {
            a=(d+sqrt(d*d-4*d))/2;
            b=(d-sqrt(d*d-4*d))/2;
            cout<<"Y ";
            printf("%.9lf %.9lf\n",a,b);

        }

    }

}

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.