結果

問題 No.1681 +-*
ユーザー kokatsukokatsu
提出日時 2021-10-14 21:51:36
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 3,162 ms
コンパイル使用メモリ 205,592 KB
実行使用メモリ 15,732 KB
最終ジャッジ日時 2023-09-04 14:28:36
合計ジャッジ時間 4,458 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 30 ms
12,108 KB
testcase_06 AC 30 ms
12,960 KB
testcase_07 AC 29 ms
12,040 KB
testcase_08 AC 47 ms
15,576 KB
testcase_09 AC 47 ms
15,488 KB
testcase_10 AC 47 ms
15,732 KB
testcase_11 AC 46 ms
14,632 KB
testcase_12 AC 46 ms
15,048 KB
testcase_13 AC 23 ms
8,856 KB
testcase_14 AC 47 ms
13,996 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 47 ms
14,020 KB
testcase_18 AC 47 ms
14,032 KB
testcase_19 AC 47 ms
13,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int N;
    readf("%d\n", N);

    auto A = readln.chomp.split.to!(long[]);

    enum long M = 10 ^^ 9 + 7;

    auto B = A.cumulativeFold!((a, b) => (a * b) % M).array;

    long res = B[N-1], c = 2;
    foreach_reverse (i; 0 .. N-1) {
        res = (res + (B[i] * c) % M) % M;
        c = (c * 3) % M;
    }

    res.writeln;
}
0