結果

問題 No.754 畳み込みの和
ユーザー ForestedForested
提出日時 2020-05-26 11:44:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 709 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 94,040 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 04:13:02
合計ジャッジ時間 1,928 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
    constexpr int mod = 1000000007;
    
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1);
    rep(i, n + 1) cin >> a[i];
    rep(i, n + 1) cin >> b[i];
    
    vector<int> s(n + 2, 0);
    rep(i, n + 1) s[i + 1] = (s[i] + b[i]) % mod;
    int ans = 0;
    rep(i, n + 1) {
        ans += (long long)a[i] * s[n - i + 1] % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
0