Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Sunday 30 October 2016

H. Simple Equation
Problem link
https://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/H

Score: 1

CPU: 1s
Memory: 512MB

Quadratic equation has two roots. Suppose those two roots are x1 and x2. We can calculate roots using the following formula. 

Smiley face
Now you will be given a, b and c. You have to calculate two roots of Quadratic Equation.

Input

Three integers ab and c will b given in one line separated with single space.

Output

Print x1 in first line and x2 in second line. Print two digits after decimal point.

Sample

InputOutput
2 4 -162.00 -4.00


Solution

#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c;
    double x1,x2;
    scanf("%d%d%d",&a,&b,&c);
    x1=(-b+sqrt((b*b)-4*a*c))/(2*a);
    x2=(-b-sqrt((b*b)-4*a*c))/(2*a);
    printf("%.2lf\n%.2lf\n",x1,x2);
    return 0;
}

No comments:

Post a Comment