結果

問題 No.754 畳み込みの和
ユーザー nasadigitalnasadigital
提出日時 2018-12-02 01:44:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 1,252 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 108,988 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 13:01:01
合計ジャッジ時間 1,550 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define MOD 1000000007

using namespace std;

typedef long long ll;


class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    ++n;
    int a[n], b[n];
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
      in >> a[ctr1];
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
      in >> b[ctr1];
    ll total = accumulate(a, a + n, 0LL) % MOD;
    ll rez = 0;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
      rez = (rez + total * b[ctr1]) % MOD, total = (total - a[n - ctr1 - 1] + MOD) % MOD;
    out << rez << "\n";
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
// Powered by caide (code generator, tester, and library code inliner)


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}

0