結果

問題 No.1681 +-*
ユーザー 👑 hitonanodehitonanode
提出日時 2021-08-08 16:21:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 5,672 ms
コンパイル使用メモリ 214,176 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 06:18:01
合計ジャッジ時間 7,026 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 21 ms
4,380 KB
testcase_06 AC 20 ms
4,380 KB
testcase_07 AC 20 ms
4,376 KB
testcase_08 AC 39 ms
4,376 KB
testcase_09 AC 39 ms
4,380 KB
testcase_10 AC 39 ms
4,376 KB
testcase_11 AC 39 ms
4,376 KB
testcase_12 AC 39 ms
4,376 KB
testcase_13 AC 20 ms
4,380 KB
testcase_14 AC 39 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 39 ms
4,380 KB
testcase_18 AC 39 ms
4,380 KB
testcase_19 AC 39 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Validator
#include "testlib.h"
#include <iostream>
#include <vector>
using namespace std;
#include <atcoder/modint>
using mint = atcoder::modint1000000007;

int main(int argc, char **argv) {
    registerValidation(argc, argv);
    int N = inf.readInt(2, 200000);
    inf.readEoln();
    vector<int> A = inf.readInts(N, 0, 1000000000);
    inf.readEoln();
    inf.readEof();

    mint ret = 0, prod = 1;
    const mint d23 = mint(2) / 3;
    for (int i = 0; i < N; i++) {
        ret *= 3;
        prod *= A[i];
        ret += prod * (i == N - 1 ? 1 : d23);
    }
    cout << ret.val() << '\n';
}
0