URI-1036 Solve

Bhaskara's Formula

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read 3 floating-point numbers. After, print the roots of bhaskara’s formula. If it's impossible to calculate the roots because a division by zero or a square root of a negative number, presents the message “Impossivel calcular”.

Input

Read 3 floating-point numbers A, B and C.

Output

Print the result with 5 digits after the decimal point or the message if it is impossible to calculate.
Input SamplesOutput Samples
10.0 20.1 5.1R1 = -0.29788
R2 = -1.71212
0.0 20.0 5.0Impossivel calcular
10.3 203.0 5.0R1 = -0.02466
R2 = -19.68408
10.0 3.0 5.0Impossivel calcular

Problem link: https://www.urionlinejudge.com.br/judge/en/problems/view/1036

Solution:

  • [tab]
    • C++
      • #include<stdio.h>
        #include <math.h>
        
        int main()
        {
         double a, b, c, t;
         scanf("%lf %lf %lf", &a, &b, &c);
        
         if(((b * b) - 4 * a * c) < 0 || a == 0){
             printf("Impossivel calcular\n");
         }
         else{
          t = sqrt((b * b) - 4 * a * c);
          printf("R1 = %.5lf\nR2 = %.5lf\n", ((-b + t) / (2 * a)), ((-b - t) / (2 * a)));
            }
         return 0;
        }
    • C
      • #include<stdio.h>
        #include <math.h>
        
        int main()
        {
         double a, b, c, t;
         scanf("%lf %lf %lf", &a, &b, &c);
        
         if(((b * b) - 4 * a * c) < 0 || a == 0){
             printf("Impossivel calcular\n");
         }
         else{
          t = sqrt((b * b) - 4 * a * c);
          printf("R1 = %.5lf\nR2 = %.5lf\n", ((-b + t) / (2 * a)), ((-b - t) / (2 * a)));
            }
         return 0;
        }
3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: URI-1036 Solve
URI-1036 Solve
DorHubs
https://dorhubs.blogspot.com/2019/08/uri-1036-solve.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/08/uri-1036-solve.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy