結果

問題 No.573 a^2[i] = a[i]
ユーザー brthyyjpbrthyyjp
提出日時 2022-02-22 09:49:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 1,954 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 80,324 KB
最終ジャッジ日時 2023-09-13 00:04:53
合計ジャッジ時間 7,886 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
77,468 KB
testcase_01 AC 89 ms
77,236 KB
testcase_02 AC 83 ms
77,436 KB
testcase_03 AC 88 ms
77,628 KB
testcase_04 AC 88 ms
77,580 KB
testcase_05 AC 88 ms
77,276 KB
testcase_06 AC 87 ms
77,212 KB
testcase_07 AC 89 ms
77,424 KB
testcase_08 AC 81 ms
77,640 KB
testcase_09 AC 88 ms
77,560 KB
testcase_10 AC 84 ms
77,556 KB
testcase_11 AC 81 ms
77,596 KB
testcase_12 AC 90 ms
77,280 KB
testcase_13 AC 80 ms
77,380 KB
testcase_14 AC 89 ms
77,356 KB
testcase_15 AC 80 ms
77,376 KB
testcase_16 AC 89 ms
77,244 KB
testcase_17 AC 80 ms
77,644 KB
testcase_18 AC 88 ms
77,580 KB
testcase_19 AC 81 ms
77,384 KB
testcase_20 AC 88 ms
77,292 KB
testcase_21 AC 81 ms
77,644 KB
testcase_22 AC 88 ms
77,276 KB
testcase_23 AC 80 ms
77,552 KB
testcase_24 AC 88 ms
77,528 KB
testcase_25 AC 80 ms
77,280 KB
testcase_26 AC 89 ms
77,216 KB
testcase_27 AC 80 ms
77,436 KB
testcase_28 AC 89 ms
77,636 KB
testcase_29 AC 80 ms
77,292 KB
testcase_30 AC 89 ms
77,236 KB
testcase_31 AC 82 ms
77,292 KB
testcase_32 AC 90 ms
77,468 KB
testcase_33 AC 81 ms
77,384 KB
testcase_34 AC 91 ms
77,368 KB
testcase_35 AC 82 ms
77,472 KB
testcase_36 AC 91 ms
77,284 KB
testcase_37 AC 83 ms
77,488 KB
testcase_38 AC 99 ms
77,284 KB
testcase_39 AC 121 ms
77,668 KB
testcase_40 AC 108 ms
77,576 KB
testcase_41 AC 86 ms
77,660 KB
testcase_42 AC 103 ms
77,908 KB
testcase_43 AC 90 ms
77,720 KB
testcase_44 AC 100 ms
77,768 KB
testcase_45 AC 94 ms
77,748 KB
testcase_46 AC 153 ms
80,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 10**5+50
mod = 10**9+7
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

def cmb1(n, r, mod):
    if r <0 or r > n:
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod

n = int(input())
ans = 0
for i in range(1, n+1):
    ans += cmb1(n, i, mod)*pow(i, n-i, mod)
    ans %= mod
print(ans)
0