yasi04

Untitled

Dec 5th, 2021
575
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. x1, x2 = map(int, input().split())
  2. y1, y2 = map(int, input().split())
  3. a = y1 * x2
  4. d = a
  5. b = y2 * x1
  6. c = b
  7. while c != 0:
  8.     d %= c
  9.     d, c = c, d
  10. x = abs(b // d)
  11. y = abs((y1 * x2) // d)
  12. if x1 < 0 and x2 > 0 or x1 > 0 and x2 < 0:
  13.     x = -1 * x
  14. if y1 < 0 and y2 > 0 or y1 > 0 and y2 < 0:
  15.     y = -1 * y
  16. print(x, y)
  17.  
  18. N, M = map(int, input().split())
  19. e = int('1' * N, 2)
  20. a = int(input(), 2)
  21. c = int('1' + '0' * (N - 1), 2)
  22. b = 0
  23. for i in range(0, M):
  24.     f, g = map(int, input().split())
  25.     if f == 1:
  26.         if (g + b) % N != 0:
  27.             z = c >> ((g + b) % N - 1)
  28.         else:
  29.             z = c >> (g + b - 1)
  30.         a = (a ^ z)
  31.     else:
  32.         b = (b + g) % N
  33. a = ((a << b) | (a >> (N - b))) & e
  34. print(bin(a)[2:].zfill(N))
RAW Paste Data