시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
40 초 (추가 시간 없음) | 1024 MB | 252 | 86 | 64 | 31.841% |
Professor Shekhu has another problem for Akki today. He has given him three positive integers A, N and P and wants him to calculate the remainder when AN! is divided by P. As usual, N! denotes the product of the first N positive integers.
The first line of the input gives the number of test cases, T. T lines follow. Each line contains three integers A, N and P, as described above.
For each test case, output one line containing Case #x: y
, where x
is the test case number (starting from 1) and y
is the answer.
2 2 1 2 3 3 2
Case #1: 0 Case #2: 1
In Sample Case #1, the answer is the remainder when 21! = 2 is divided by 2, which is 0.
In Sample Case #2, the answer is the remainder when 33! = 36 = 729 is divided by 2, which is 1.
Contest > Google > Kick Start > Google Kick Start 2017 > Round G A번