結果

問題 No.129 お年玉(2)
ユーザー mkawa2
提出日時 2019-12-24 13:27:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
MLE  
実行時間 -
コード長 901 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 692,856 KB
最終ジャッジ日時 2024-09-21 21:30:57
合計ジャッジ時間 10,155 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 MLE * 1 -- * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

md = 10 ** 9
memo = {}

def com(com_n, com_r):
    if com_n < com_r * 2: com_r = com_n - com_r
    if (com_n, com_r) in memo: return memo[(com_n, com_r)]
    if com_r == 1: return com_n
    if com_r == 0: return 1
    res = memo[(com_n, com_r)] = (com(com_n - 1, com_r) + com(com_n - 1, com_r - 1)) % md
    return res

def main():
    n = II()
    m = II()
    n //= 1000
    hit = n % m
    print(com(m, hit))

main()
0