mipt 075. Root of the equation

MasterRay posted @ 2010年3月09日 01:33 , 1509 阅读

mipt 的 python 版本太旧了,可能还没有 decimal

 1 #!/usr/bin/env python
 2
 3 import decimal
 4 from math import exp, log
 5
 6 def read_str():
 7     while True:
 8         s = raw_input()
 9         if s.strip():
10             break
11     return s
12
13 def main():
14     decimal.getcontext().prec = 30
15
16     s = decimal.Decimal(read_str())
17     if 0 <= s <= 2:
18         print (s.ln() / s).exp().quantize(decimal.Decimal('0.'+'0'*19))
19     else:
20         print 'NO'
21
22 main()


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter