Advertisement
Korotkodul

1B

Sep 27th, 2023 (edited)
937
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import math
  2. from decimal import Decimal, getcontext
  3.  
  4. getcontext().prec = 6
  5.  
  6. n = int(input())
  7. a = input().split()
  8. b = []
  9. for i in range(n):
  10.     k = float(a[i]) * 100
  11.     k = int(k)
  12.     b.append(k)
  13. #print(b)
  14. pf = [0] * n
  15. pf[0] = b[0]
  16. for i in range(1, n):
  17.     pf[i] = pf[i - 1] * b[i]
  18. q = int(input())
  19. #print(b)
  20. #print(pf)
  21. for i in range(q):
  22.     s = input().split()
  23.     l = int(s[0])
  24.     l -= 1
  25.     r = int(s[1])
  26.     div = 1
  27.     if l > -1:
  28.         div = pf[l]
  29.     print(div, pf[r])
  30.     res = pf[r] * 1.0 / div
  31.     print(res)
  32.     res = math.pow(res, 1.0 / (r - l)) / 100
  33.     print(Decimal(res))
  34.     print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement