結果

問題 No.754 畳み込みの和
ユーザー kyunakyuna
提出日時 2019-07-18 22:32:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 508 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 72,476 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 20:35:45
合計ジャッジ時間 1,697 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
4,376 KB
testcase_01 AC 71 ms
4,380 KB
testcase_02 AC 71 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;

int main() {
    int n; cin >> n;
    vector<int> a(n + 1), b(n + 1);
    for (int &ai: a) cin >> ai;
    for (int &bi: b) cin >> bi;
    vector<int> acc_b(n + 2);
    for (int i = 0; i <= n; i++) (acc_b[i + 1] = acc_b[i] + b[i]) %= MOD;
    int sum = 0;
    for (int i = 0; i <= n; i++) {
        (sum += 1LL * a[i] * acc_b[n - i + 1] % MOD) %= MOD;
    }
    cout << sum << endl;
    return 0;
}
0