結果

問題 No.1681 +-*
ユーザー kohei2019kohei2019
提出日時 2022-07-01 00:17:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 674 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 106,488 KB
最終ジャッジ日時 2023-08-16 12:02:39
合計ジャッジ時間 12,974 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,188 KB
testcase_01 AC 71 ms
71,360 KB
testcase_02 AC 89 ms
76,060 KB
testcase_03 AC 92 ms
77,008 KB
testcase_04 AC 95 ms
77,348 KB
testcase_05 AC 627 ms
106,128 KB
testcase_06 AC 586 ms
106,332 KB
testcase_07 AC 578 ms
106,488 KB
testcase_08 AC 672 ms
101,564 KB
testcase_09 AC 627 ms
101,644 KB
testcase_10 AC 667 ms
101,680 KB
testcase_11 AC 630 ms
101,572 KB
testcase_12 AC 662 ms
101,852 KB
testcase_13 AC 352 ms
92,580 KB
testcase_14 AC 619 ms
101,396 KB
testcase_15 AC 70 ms
71,184 KB
testcase_16 AC 71 ms
71,348 KB
testcase_17 AC 674 ms
101,584 KB
testcase_18 AC 633 ms
101,484 KB
testcase_19 AC 626 ms
101,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def modPow(a,n,mod):#繰り返し二乗法 a**n % mod
    if n==0:
        return 1
    if n==1:
        return a%mod
    if n & 1:
        return (a*modPow(a,n-1,mod)) % mod
    t = modPow(a,n>>1,mod)
    return (t*t)%mod
N = int(input())
lsA = list(map(int,input().split()))
mod = 10**9+7

l = 1
ans = 0
for i in range(N-1):
    l *= lsA[i]
    l %= mod
    ans += l*2*modPow(3,N-2-i,mod)
    ans %= mod
l *= lsA[N-1]
ans += l
ans %= mod
print(ans)
0