結果

問題 No.573 a^2[i] = a[i]
ユーザー realDivineJKrealDivineJK
提出日時 2020-05-27 11:23:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 645 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 18,688 KB
最終ジャッジ日時 2024-04-21 05:07:55
合計ジャッジ時間 7,804 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
18,560 KB
testcase_01 AC 115 ms
18,560 KB
testcase_02 AC 116 ms
18,560 KB
testcase_03 AC 114 ms
18,560 KB
testcase_04 AC 120 ms
18,560 KB
testcase_05 AC 123 ms
18,560 KB
testcase_06 AC 116 ms
18,560 KB
testcase_07 AC 117 ms
18,560 KB
testcase_08 AC 115 ms
18,560 KB
testcase_09 AC 113 ms
18,688 KB
testcase_10 AC 121 ms
18,560 KB
testcase_11 AC 114 ms
18,560 KB
testcase_12 AC 116 ms
18,560 KB
testcase_13 AC 121 ms
18,560 KB
testcase_14 AC 118 ms
18,688 KB
testcase_15 AC 114 ms
18,688 KB
testcase_16 AC 123 ms
18,560 KB
testcase_17 AC 131 ms
18,560 KB
testcase_18 AC 115 ms
18,688 KB
testcase_19 AC 119 ms
18,560 KB
testcase_20 AC 120 ms
18,560 KB
testcase_21 AC 114 ms
18,560 KB
testcase_22 AC 118 ms
18,560 KB
testcase_23 AC 114 ms
18,560 KB
testcase_24 AC 114 ms
18,688 KB
testcase_25 AC 124 ms
18,560 KB
testcase_26 AC 115 ms
18,560 KB
testcase_27 AC 115 ms
18,688 KB
testcase_28 AC 116 ms
18,560 KB
testcase_29 AC 117 ms
18,560 KB
testcase_30 AC 114 ms
18,560 KB
testcase_31 AC 116 ms
18,560 KB
testcase_32 AC 113 ms
18,560 KB
testcase_33 AC 116 ms
18,560 KB
testcase_34 AC 115 ms
18,560 KB
testcase_35 AC 119 ms
18,560 KB
testcase_36 AC 124 ms
18,560 KB
testcase_37 AC 121 ms
18,688 KB
testcase_38 AC 119 ms
18,688 KB
testcase_39 AC 122 ms
18,560 KB
testcase_40 AC 121 ms
18,560 KB
testcase_41 AC 123 ms
18,688 KB
testcase_42 AC 137 ms
18,688 KB
testcase_43 AC 129 ms
18,560 KB
testcase_44 AC 136 ms
18,560 KB
testcase_45 AC 158 ms
18,688 KB
testcase_46 AC 645 ms
18,688 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