목차

N포커

ps
링크acmicpc.net/…
출처BOJ
문제 번호16565
문제명N포커
레벨골드 1
분류

포함배제의 원리

시간복잡도O(n)
인풋사이즈n<=52
사용한 언어Python
제출기록31312KB / 68ms
최고기록60ms
해결날짜2021/10/18

풀이

코드

"""Solution code for "BOJ 16565. N포커".

- Problem link: https://www.acmicpc.net/problem/16565
- Solution link: http://www.teferi.net/ps/problems/boj/16565

Tags: [Inclusion-Exclusion Principle]
"""

import math

MOD = 10007


def main():
    N = int(input())
    answer = 0
    for i in range(1, N // 4 + 1):
        count = math.comb(13, i) * math.comb(52 - 4 * i, N - 4 * i)
        answer += count if i % 2 else -count
    print(answer % MOD)


if __name__ == '__main__':
    main()