fork(11) download
  1. import sys
  2.  
  3. def remaining( n, k):
  4. r = 0
  5. i = 2
  6. while i <= n:
  7. r = (r + k) % i;
  8. i+= 1
  9. return r+1
  10.  
  11. cases= int(sys.stdin.readline())
  12. current= 0
  13. while current < cases:
  14. current += 1
  15. n = int(sys.stdin.readline())
  16. print remaining(n, 2)
Success #stdin #stdout 3.98s 8840KB
stdin
4
5
11
45
23987443
stdout
3
7
27
14420455