結果

問題 No.754 畳み込みの和
ユーザー m1025o1184tm1025o1184t
提出日時 2019-12-20 04:32:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 750 bytes
コンパイル時間 1,863 ms
コンパイル使用メモリ 166,112 KB
実行使用メモリ 9,164 KB
最終ジャッジ日時 2023-09-21 12:37:29
合計ジャッジ時間 14,541 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll mod = 1000000007;
	int n;
	cin >> n;
	vector<ll> a(n + 1);
	vector<ll> b(n + 1);
	rep(i, n + 1) cin >> a[i];
	rep(i, n + 1) cin >> b[i];
	

	ll resa = 0;
	ll resb = 0;
	rep(i, n + 1) resa += a[i];
	rep(i, n + 1) resb += b[i];

	resa %= mod;
	resb %= mod;

	ll ans = resa * resb;
	ans %= mod;

	ll resa_no = 0;

	for (int i = 1; i < n + 1; ++i) {
		for (int j = n; j >= n - i + 1; --j) {
			resa_no += (a[i] * b[j])%mod;
		}
	}
	ans -= resa_no;

	while (ans < 0) {
		ans += mod;
	}

	dunk(ans);

	return 0;
}
0