fork(11) download
  1. def josephus_2( n ):
  2. from math import log
  3. return 2*(n - 2**(int(log(n,2))))+1
  4. cases= int(raw_input())
  5. current= 0
  6. while current < cases:
  7. current += 1
  8. n = int(raw_input())
  9. print josephus_2( n )
Success #stdin #stdout 0.01s 7696KB
stdin
5
5
11
45
23987443
100
stdout
3
7
27
14420455
73