## p84ex5 - Equation

Given the real coefficients a and b (-1000 ≤ a, b ≤ 1000), solve for x in the following equation.

ax + b = 0

Be sure to output "indeterminate" and "undefined" whenever appropriate. Remember 0/0 is indeterminate, and something like 4/0 is undefined.

Output the value of x rounded to two decimal places.

### Input

The input cosists of two real numbers, a and b. a and b will be on separate lines, with a first, and b second.

### Output

Output the value of x according to the given values and equation. Be sure to output "indeterminate" and "undefined" whenever appropriate.

10
5

-0.50

13.5555
1.244685

-0.09

0
0

indeterminate

0
4

### Sample Output 4

undefined

Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 20, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

• (0/0)
My code works for all cases when I submitted it except the first. I got 10/10 in all cases, but in the first I got 0/10. Can someone hint to me what I'm doing wrong? I've read over the question 10 times and I'm almost 100% sure I've met all the parameters.

• (0/0)
Your code fails on sample case 1.

• (0/0)
I know why my errors happen. Inputs like -.5 would cause an InputMismatchException, yet -.5 clearly means -0.5. And yet things like .5 works. How the heck do I solve this problem?

• (1/0)
I don't think .5 works on your code. It isn't an int, so you can't read it with nextInt().

• (1/0)
At first i forgot to round and now i dont know help

• (0/0)
setprecision doesn't quite work how you think it does.

• (0/0)
Use ciel

• (0/0)
Can someone please tell me what is wrong with my code? I believe I'm using setprecision correctly.

• (0/0)
I'm having trouble with the first test case and I have no idea what the issue is. Can anyone help?

• (1/0)
1. Don't use float, double is better

2. Don't use roundf, instead use
cout << fixed << setprecision(2) << ...

• (0/0)
Thanks!