ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 11402 |
문제명 | 이항 계수 4 |
레벨 | 플래티넘 5 |
분류 |
수학, 정수론 |
시간복잡도 | O(m + logn/logm) |
인풋사이즈 | n<=10^18, m<=2000 |
사용한 언어 | Python |
제출기록 | 28776KB / 64ms |
최고기록 | 56ms |
해결날짜 | 2021/01/20 |
from teflib import combinatorics
def main():
N, K, M = [int(x) for x in input().split()]
comb_table = combinatorics.CombTable(M - 1, M)
answer = 1
while N > 0:
N, n_mod = divmod(N, M)
K, k_mod = divmod(K, M)
answer *= comb_table.get(n_mod, k_mod)
print(answer % M)
if __name__ == '__main__':
main()