結果

問題 No.129 お年玉(2)
ユーザー kozykozy
提出日時 2020-07-22 20:20:56
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 631 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 8,508 KB
最終ジャッジ日時 2023-09-04 04:44:24
合計ジャッジ時間 2,895 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,796 KB
testcase_01 AC 17 ms
7,788 KB
testcase_02 AC 18 ms
7,880 KB
testcase_03 AC 17 ms
7,824 KB
testcase_04 AC 16 ms
7,832 KB
testcase_05 AC 18 ms
7,968 KB
testcase_06 AC 21 ms
8,252 KB
testcase_07 AC 20 ms
8,344 KB
testcase_08 AC 18 ms
7,732 KB
testcase_09 AC 19 ms
8,256 KB
testcase_10 AC 19 ms
8,360 KB
testcase_11 AC 20 ms
8,424 KB
testcase_12 AC 17 ms
7,772 KB
testcase_13 AC 16 ms
7,788 KB
testcase_14 AC 21 ms
8,484 KB
testcase_15 AC 19 ms
8,384 KB
testcase_16 AC 20 ms
8,484 KB
testcase_17 AC 19 ms
8,312 KB
testcase_18 AC 19 ms
8,292 KB
testcase_19 AC 17 ms
8,168 KB
testcase_20 AC 21 ms
8,472 KB
testcase_21 AC 19 ms
8,356 KB
testcase_22 AC 19 ms
8,296 KB
testcase_23 AC 19 ms
8,508 KB
testcase_24 AC 17 ms
7,812 KB
testcase_25 AC 20 ms
8,336 KB
testcase_26 AC 18 ms
8,256 KB
testcase_27 AC 18 ms
8,172 KB
testcase_28 AC 21 ms
8,336 KB
testcase_29 AC 16 ms
7,820 KB
testcase_30 AC 16 ms
7,860 KB
testcase_31 AC 16 ms
7,824 KB
testcase_32 AC 16 ms
7,820 KB
testcase_33 AC 16 ms
7,784 KB
testcase_34 AC 16 ms
7,824 KB
testcase_35 AC 16 ms
7,812 KB
testcase_36 AC 17 ms
7,824 KB
testcase_37 AC 17 ms
7,872 KB
testcase_38 AC 17 ms
8,236 KB
testcase_39 AC 17 ms
8,304 KB
testcase_40 AC 18 ms
8,308 KB
testcase_41 AC 19 ms
8,400 KB
testcase_42 AC 17 ms
8,308 KB
testcase_43 AC 17 ms
7,928 KB
testcase_44 AC 18 ms
8,200 KB
testcase_45 AC 18 ms
7,800 KB
testcase_46 AC 16 ms
7,864 KB
testcase_47 AC 19 ms
8,296 KB
testcase_48 AC 18 ms
7,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
N=int(input())
M=int(input())
N=N%(M*1000)
N=N//1000
print(cmb(M,N)%(10**9))
0