結果

問題 No.754 畳み込みの和
ユーザー HaarHaar
提出日時 2018-12-02 15:53:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 932 bytes
コンパイル時間 1,508 ms
コンパイル使用メモリ 167,184 KB
実行使用メモリ 5,492 KB
最終ジャッジ日時 2023-09-13 20:49:54
合計ジャッジ時間 2,138 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

const LLI mod = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;

  vector<LLI> a(n+1), b(n+1);
  REPE(i,n) cin >> a[i];
  REPE(i,n) cin >> b[i];

  vector<LLI> bsum(n+1, b[0]);
  FORE(i,1,n) (bsum[i] = bsum[i-1] + b[i]) %= mod;

  LLI ans = 0;
  REPE(i,n) (ans += a[i] * bsum[n-i]) %= mod;

  cout << ans << endl;
  
  return 0;
}
0