Advertisement
Guest User

Untitled

a guest
May 2nd, 2015
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. N = int(input())
  2. cnd = [0] * N
  3. c = [0] * N
  4. for i in range(N):
  5.     s = input().split()
  6.     M = int(s[1]) % int(s[0])
  7.     for j in range(N):
  8.         if M == cnd[j] and M != 0:
  9.             c[j] += 1
  10.     cnd[i] = M
  11. mMax = 0
  12. d = 0
  13. for i in range(N):
  14.     if c[i] > mMax:
  15.         mMax = c[i]
  16.         d = i
  17.     if c[i] == mMax:
  18.         if cnd[i] > cnd[d]:
  19.             d = i
  20. print(cnd[d])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement