結果

問題 No.1681 +-*
ユーザー wa kyawa kya
提出日時 2021-09-20 22:05:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 73,412 KB
実行使用メモリ 4,744 KB
最終ジャッジ日時 2023-09-15 21:22:09
合計ジャッジ時間 4,383 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

int main(){
    long ans = 0;
    long N; cin >> N;
    long P = 1;
    long C;
    vector<long> b(N, 1);
    b[N - 2] = 2; for(long i = N - 3; i >= 0; i--) {b[i] = b[i + 1] * 3; b[i] %= (long)1e9+7;}
    for(long i = 0; i < N; i++){
        cin >> C;
        P *= C; P %= (long)1e9+7;
        ans += P * b[i]; ans %= (long)1e9+7;
    }
    ans %= (long)1e9+7;
    cout << ans << endl;
}
0