結果

問題 No.1681 +-*
ユーザー hourenhouren
提出日時 2021-09-17 23:49:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 166,760 KB
実行使用メモリ 4,908 KB
最終ジャッジ日時 2023-09-12 10:03:55
合計ジャッジ時間 3,474 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll x = 1, k = 2;
    rep(i,n){
        ll p;
        cin >> p;
        x = x * p % MOD;
        a[i] = x;
    }
    ll ans = a[n-1];
    rep(i,n-1){
        ans = (ans + a[n-i-2] * k) % MOD;
        k = k * 3 % MOD;
    }
    cout << ans << endl;
    return 0;
}
0