fork download
  1. def point_color(x, y):
  2. while x > 0 and y > 0:
  3. if y > x // 2:
  4. y = x + 1 - y
  5. x = x // 2
  6. return 1 if y == 1 else 0
  7.  
  8. # Read input
  9. import sys
  10. input = sys.stdin.read
  11. data = input().split()
  12.  
  13. Q = int(data[0])
  14. queries = [(int(data[2 * i + 1]), int(data[2 * i + 2])) for i in range(Q)]
  15.  
  16. # Answer the queries
  17. results = []
  18. for x, y in queries:
  19. results.append(point_color(x, y))
  20.  
  21. # Print results
  22. print("\n".join(map(str, results)))
  23.  
Success #stdin #stdout 0.04s 9784KB
stdin
6
1 1
5 3
8 2
8 6
5 4
6 4
stdout
1
0
1
1
1
1