結果

問題 No.1011 Infinite Stairs
ユーザー realDivineJKrealDivineJK
提出日時 2020-05-18 23:43:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 15,324 KB
最終ジャッジ日時 2023-09-24 11:14:58
合計ジャッジ時間 2,288 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,832 KB
testcase_01 AC 17 ms
7,760 KB
testcase_02 AC 17 ms
8,328 KB
testcase_03 AC 64 ms
13,292 KB
testcase_04 AC 24 ms
9,012 KB
testcase_05 AC 84 ms
15,324 KB
testcase_06 AC 15 ms
7,816 KB
testcase_07 AC 17 ms
8,384 KB
testcase_08 AC 16 ms
7,960 KB
testcase_09 AC 17 ms
7,832 KB
testcase_10 AC 18 ms
8,268 KB
testcase_11 AC 26 ms
9,192 KB
testcase_12 AC 17 ms
8,360 KB
testcase_13 AC 27 ms
9,504 KB
testcase_14 AC 16 ms
7,828 KB
testcase_15 AC 26 ms
9,216 KB
testcase_16 AC 51 ms
11,920 KB
testcase_17 AC 18 ms
8,556 KB
testcase_18 AC 41 ms
11,108 KB
testcase_19 AC 17 ms
8,408 KB
testcase_20 AC 16 ms
8,208 KB
testcase_21 AC 34 ms
10,152 KB
testcase_22 AC 34 ms
10,312 KB
testcase_23 AC 38 ms
10,552 KB
testcase_24 AC 33 ms
10,128 KB
testcase_25 AC 35 ms
10,376 KB
testcase_26 AC 25 ms
9,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, d, K = map(int, input().split())
mod = int(1e9)+7
def inved(a):
    x, y, u, v, k, l = 1, 0, 0, 1, a, mod
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return x % mod
    
fact = [1 for _ in range(N+K+1)]
invf = [1 for _ in range(N+K+1)]
for i in range(N+K):
    fact[i+1] = (fact[i]*(i+1))%mod
invf[-1] = inved(fact[-1])
for i in range(N+K, 0, -1):
    invf[i-1] = (invf[i] * i) % mod
    
S = 0
sign = 1
for i in range(N+1):
    if K-i*d-N < 0:
        break
    else:
        S += (sign * fact[K-1-i*d] * invf[i] * invf[N-i] * invf[K-i*d-N]) % mod
        S %= mod
        sign *= mod - 1
        sign %= mod
print((N*S)%mod)
0