結果

問題 No.1681 +-*
ユーザー hitonanode
提出日時 2021-08-02 20:32:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 72,684 KB
最終ジャッジ日時 2025-01-23 13:43:52
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
#include <atcoder/modint>
using mint = atcoder::modint1000000007;

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

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