結果

問題 No.1681 +-*
ユーザー 👑 tatyam
提出日時 2021-09-17 21:25:38
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 247,180 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 19:48:06
合計ジャッジ時間 4,274 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using Modint = atcoder::modint1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int& a : A) cin >> a;
    Modint ans = 0, c = 1;
    for(int a : A){
        ans *= 3;
        c *= Modint::raw(a);
        ans += c;
    }
    ans -= c;
    ans *= Modint::raw(2) / Modint::raw(3);
    ans += c;
    cout << ans.val() << endl;
}
0