Algorithm


Problem link- https://www.spoj.com/problems/TRIGALGE/

TRIGALGE - Easy Calculation

 

Find x such that Ax+Bsin(x)=C.

Input

The first line denotes T (number of test cases). 3T integers follow denoting A,B and C for every test case. (A >= B > 0). All Integers are less than 100000.

Output

T real numbers rounded to 6 digits one in each line.

Example

Input:
1
1 1 20

Output:
19.441787

 

Code Examples

#1 Code Example with Python Programming

Code - Python Programming

import math

T = int(input())
for _ in range(T):
    A, B, C = map(float, input().split())
    low, high = 0.0, C
    for i in range(50):
        middle = (low + high) / 2.0
        f = A * middle + B * math.sin(middle)
        if f >= C:
            high = middle
        else:
            low = middle
    print('%.6f' %low)
Copy The Code & Try With Live Editor

Input

x
+
cmd
1
1 1 20

Output

x
+
cmd
19.441787
Advertisements

Demonstration


SPOJ Solution-Easy Calculation-Solution in C, C++, Java, Python

Previous
SPOJ Solution - Test Life, the Universe, and Everything - Solution in C, C++, Java, Python