fork download
  1. def reader(inFile):
  2. return tuple(inFile.getInts())
  3.  
  4. def solver((N, p)):
  5. wins = [(((p - 1) >> i) & 1) == 0 for i in xrange(N)][::-1]
  6. a1 = 0
  7. for win in wins:
  8. if not win:
  9. a1 += 1
  10. else:
  11. break
  12. a1 = ((1 << (a1 + 1)) - 2) if (a1 < N) else ((1 << N) - 1)
  13. a2 = 0
  14. for win in wins:
  15. if win:
  16. a2 += 1
  17. else:
  18. break
  19. if (a2 == len([win for win in wins if win])):
  20. a2 -= 1
  21. a2 = (1 << N) - (1 << (a2 + 1))
  22. return "%d %d" % (a1, a2)
  23.  
  24. if __name__ == "__main__":
  25. from GCJ import GCJ
  26. GCJ(reader, solver, "/Users/lpebody/gcj/2013_2/b/", "b").run()
  27.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty