xah

Problem B: Geometric Progressions

xah
Apr 3rd, 2017 (edited)
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. n = int(input())
  2.  
  3. for nn in range(n):
  4.     sample = input().split()
  5.  
  6.     sample = [int(s) for s in sample]
  7.  
  8.     ratio = sample[2] / sample[1]
  9.     total = 1
  10.     stuff = True
  11.  
  12.     for s in sample:
  13.         if s == 1:
  14.             continue
  15.         else:
  16.             total *= ratio
  17.  
  18.             if total != s:
  19.                 print('no')
  20.                 stuff = False
  21.                 break
  22.  
  23.     if stuff:
  24.         print('yes', int(ratio))
Advertisement
Add Comment
Please, Sign In to add comment