fork(1) download
  1. n , mod = map(int , raw_input().split())
  2. n += 1 ^ (n & 1)
  3. fact = [0] * n
  4. fact[0] = 1
  5. for i in range(1 , n):
  6. fact[i] = (fact[i - 1] * i) % mod
  7. ifact = [0] * n
  8. ifact[n - 1] = pow(fact[n - 1] , mod - 2 , mod)
  9. for i in range(0 , n - 1):
  10. ifact[n - i - 2] = (ifact[n - i - 1] * (n - i - 1)) % mod
  11. def c(n , r):
  12. return (fact[n] * ifact[r] * ifact[n - r]) % mod
  13. def solve(x):
  14. if x == 1:
  15. return 1
  16. res = solve(x >> 1)
  17. res *= res
  18. res %= mod
  19. res *= c(x - 1 , x >> 1)
  20. res %= mod
  21. return res
  22. print solve(n)
Runtime error #stdin #stdout #stderr 0.01s 8968KB
stdin
Author Python Solution
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'Author'