結果

問題 No.1681 +-*
ユーザー 👑 hitonanodehitonanode
提出日時 2021-08-08 16:40:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 543 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 74,364 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 06:18:34
合計ジャッジ時間 2,583 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// WA 最後の項を処理した後 mod とり忘れ
#include <iostream>
#include <vector>
using namespace std;
#include <atcoder/modint>
using mint = atcoder::modint1000000007;

int main() {
    int N;
    cin >> N;
    long long ret = 0;
    mint prod = 1;

    const mint d23 = mint(2) / 3;
    for (int i = 0; i < N; i++) {
        ret = (mint(ret) * 3).val();
        int a;
        cin >> a;
        prod *= mint(a);
        if (i < N - 1) ret = (mint(ret) + (prod * d23)).val();
    }
    ret += prod.val();
    cout << ret << '\n';
}
0