結果

問題 No.741 AscNumber(Easy)
ユーザー maninimanini
提出日時 2021-01-26 11:59:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 71,588 KB
最終ジャッジ日時 2023-09-05 16:12:23
合計ジャッジ時間 6,805 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,180 KB
testcase_01 AC 74 ms
71,336 KB
testcase_02 AC 79 ms
71,340 KB
testcase_03 AC 74 ms
71,228 KB
testcase_04 AC 74 ms
71,304 KB
testcase_05 AC 75 ms
71,240 KB
testcase_06 AC 74 ms
71,140 KB
testcase_07 AC 74 ms
71,192 KB
testcase_08 AC 74 ms
71,224 KB
testcase_09 AC 75 ms
71,588 KB
testcase_10 AC 73 ms
71,272 KB
testcase_11 AC 76 ms
71,144 KB
testcase_12 AC 76 ms
71,296 KB
testcase_13 AC 75 ms
71,140 KB
testcase_14 AC 77 ms
71,188 KB
testcase_15 AC 76 ms
71,576 KB
testcase_16 AC 75 ms
71,540 KB
testcase_17 AC 73 ms
71,464 KB
testcase_18 AC 75 ms
71,364 KB
testcase_19 AC 74 ms
71,144 KB
testcase_20 AC 75 ms
71,544 KB
testcase_21 AC 75 ms
71,200 KB
testcase_22 AC 77 ms
71,564 KB
testcase_23 AC 75 ms
71,220 KB
testcase_24 AC 77 ms
71,284 KB
testcase_25 AC 73 ms
71,252 KB
testcase_26 AC 73 ms
71,140 KB
testcase_27 AC 74 ms
71,412 KB
testcase_28 AC 74 ms
71,184 KB
testcase_29 AC 75 ms
71,540 KB
testcase_30 AC 72 ms
71,292 KB
testcase_31 AC 73 ms
71,480 KB
testcase_32 AC 75 ms
71,416 KB
testcase_33 AC 75 ms
71,476 KB
testcase_34 AC 74 ms
71,340 KB
testcase_35 AC 75 ms
71,252 KB
testcase_36 AC 74 ms
71,336 KB
testcase_37 AC 76 ms
70,996 KB
testcase_38 AC 74 ms
71,520 KB
testcase_39 AC 75 ms
71,300 KB
testcase_40 AC 77 ms
71,340 KB
testcase_41 AC 78 ms
71,588 KB
testcase_42 AC 77 ms
71,456 KB
testcase_43 AC 76 ms
71,220 KB
testcase_44 AC 74 ms
71,220 KB
testcase_45 AC 76 ms
71,016 KB
testcase_46 AC 76 ms
71,188 KB
testcase_47 AC 76 ms
71,564 KB
testcase_48 AC 76 ms
71,236 KB
testcase_49 AC 77 ms
71,228 KB
testcase_50 AC 78 ms
71,236 KB
testcase_51 AC 75 ms
71,404 KB
testcase_52 AC 75 ms
71,540 KB
testcase_53 AC 76 ms
71,360 KB
testcase_54 AC 75 ms
71,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:UTF-8
import sys

MOD = 10 ** 9 + 7
INF = float('inf')

# 拡張ユークリッド互除法
# ax + by = g
def extGcd(a, b):
    if b == 0:
        return [a, 1, 0]
    else:
        g, x, y = extGcd(b, a%b)
        return [g, int(y), int(x - (a // b) * y)]

# 逆元
def inv(a):
    r = extGcd(a, MOD)
    return r[1] % MOD

def comb(n, k):
    if n < k:
        return 0
    elif n < 0 or k < 0:
        return 0
    a = 1
    for i in range(k):
        a = a * (n - i) % MOD
    b = 1
    for i in range(1, k+1):
        b = b * i % MOD
    binv = inv(b)
    return (a * binv) % MOD

N = int(input())    # 数字

res = 1
for i in range(1, 10):
    t = comb(9, i)
    # t2 = 0
    # for j in range(1, N+1):
    #     t2 = (t2 + comb(j-1, i-1, f)) % MOD
    t2 = comb(N, i)
    res = (res + t * t2) % MOD

print("{}".format(res))
0