Fast Factorial Calculator 3

View as PDF

Submit solution

Points: 40
Time limit: 0.4s
Memory limit: 1G

Problem type

ho94949 is in a good mood today. He discovered a secret method to compute large factorials very quickly. Can you beat him?

Input Specification

The first and only line of input contains two positive integers, N and P.

You may assume 1 \le N < P \le 10^{10}, and that P is prime.

Output Specification

Print N! \pmod{P}.

Sample Input

9999999966 9999999967

Sample Output

9999999966

Comments


  • 0
    vsarca  commented on Nov. 22, 2023, 5:24 a.m.

    Fast Factorial Calculator 4 when?