天天看點

UVA 10341 Solve It

problem f

solve it

input: standard input

output: standard output

time limit: 1 second

memory limit: 32 mb

solve the equation:

p*e-x + q*sin(x) + r*cos(x) + s*tan(x) + t*x2 + u = 0

where 0 <= x <=

1.

input

input consists of multiple test cases and terminated by an eof.

each test case consists of

6 integers in a single line: p, q, r, s, t and u

(where 0 <= p,r <= 20 and -20 <=

q,s,t <= 0). there will be

maximum 2100 lines in the input file.

output

for each set of input,

there should be a line containing the value of x, correct upto 4

decimal

places, or the string "no solution", whichever is applicable.

sample input

0 0 0 0 -2 1

1 0 0 0 -1 2

1 -1 1 -1 -1 1

sample output

0.7071

no solution

0.7554

首先對函數求導,發現是一個遞減函數,這樣就可以用二分求答案了,不過這個題精度要求好高啊,必須到10^-8次啊,一開始弄了一個10^-6,結果wa了,看來很久沒有感覺有錯誤,就改了一下8就通過了,暈啊!