結果

問題 No.573 a^2[i] = a[i]
ユーザー realDivineJKrealDivineJK
提出日時 2020-05-27 11:23:12
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 523 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 16,328 KB
最終ジャッジ日時 2023-08-03 05:56:30
合計ジャッジ時間 7,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
16,312 KB
testcase_01 AC 88 ms
16,292 KB
testcase_02 AC 88 ms
16,220 KB
testcase_03 AC 87 ms
16,268 KB
testcase_04 AC 85 ms
16,140 KB
testcase_05 AC 94 ms
16,136 KB
testcase_06 AC 93 ms
16,292 KB
testcase_07 AC 92 ms
16,108 KB
testcase_08 AC 91 ms
16,184 KB
testcase_09 AC 88 ms
16,228 KB
testcase_10 AC 86 ms
16,224 KB
testcase_11 AC 88 ms
16,220 KB
testcase_12 AC 89 ms
16,148 KB
testcase_13 AC 86 ms
16,224 KB
testcase_14 AC 89 ms
16,288 KB
testcase_15 AC 87 ms
16,228 KB
testcase_16 AC 88 ms
16,184 KB
testcase_17 AC 91 ms
16,224 KB
testcase_18 AC 87 ms
16,248 KB
testcase_19 AC 87 ms
16,328 KB
testcase_20 AC 88 ms
16,104 KB
testcase_21 AC 90 ms
16,240 KB
testcase_22 AC 87 ms
16,180 KB
testcase_23 AC 86 ms
16,280 KB
testcase_24 AC 88 ms
16,220 KB
testcase_25 AC 92 ms
16,228 KB
testcase_26 AC 86 ms
16,180 KB
testcase_27 AC 86 ms
16,156 KB
testcase_28 AC 86 ms
16,200 KB
testcase_29 AC 88 ms
16,256 KB
testcase_30 AC 87 ms
16,156 KB
testcase_31 AC 86 ms
16,132 KB
testcase_32 AC 87 ms
16,204 KB
testcase_33 AC 89 ms
16,152 KB
testcase_34 AC 89 ms
16,272 KB
testcase_35 AC 86 ms
16,136 KB
testcase_36 AC 90 ms
16,108 KB
testcase_37 AC 92 ms
16,136 KB
testcase_38 AC 94 ms
16,292 KB
testcase_39 AC 89 ms
16,136 KB
testcase_40 AC 93 ms
16,144 KB
testcase_41 AC 93 ms
16,132 KB
testcase_42 AC 98 ms
16,236 KB
testcase_43 AC 97 ms
16,296 KB
testcase_44 AC 103 ms
16,272 KB
testcase_45 AC 126 ms
16,236 KB
testcase_46 AC 523 ms
16,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = int(1e9) + 7
maxf = int(1e5) # <-- input factional limitation

def doubling(n, m):
    y = 1
    base = n
    tmp = m
    while tmp != 0:
        if tmp % 2 == 1:
            y *= base
            y %= mod
        base *= base
        base %= mod
        tmp //= 2
    return y

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(maxf+1)]
invf = [1 for _ in range(maxf+1)]

for i in range(maxf):
    fact[i+1] = (fact[i] * (i+1)) % mod
invf[-1] = inved(fact[-1])
for i in range(maxf, 0, -1):
    invf[i-1] = (invf[i] * i) % mod
    
N = int(input())
S = 0
sgn = mod - 1
for i in range(1, N+1):
    S += ((invf[i] * invf[N-i]) % mod) * doubling(i, N - i) % mod
    S %= mod
S *= fact[N]
S %= mod
print(S)
0