結果

問題 No.129 お年玉(2)
コンテスト
ユーザー mkawa2
提出日時 2019-12-24 13:27:29
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 901 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 393 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 1,015,112 KB
最終ジャッジ日時 2026-04-10 03:12:59
合計ジャッジ時間 15,213 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 TLE * 1 MLE * 1 -- * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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