結果

問題 No.754 畳み込みの和
ユーザー 3_3_nk3_3_nk
提出日時 2020-09-11 10:30:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,490 bytes
コンパイル時間 1,361 ms
コンパイル使用メモリ 166,432 KB
実行使用メモリ 15,036 KB
最終ジャッジ日時 2023-08-26 15:18:04
合計ジャッジ時間 14,405 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------
void print(vector<ll> a, vector<ll> b){
	cout << "(";
	REP(i, a.size()){
		if(i != 0){
			cout << " + ";
		}
		cout << a[i];
		if(i != 0){
			cout << "x";
			if(i >= 2){
				cout << "^" << i;
			}
		}
	}
	cout << ")(";
	REP(i, b.size()){
		if(i != 0){
			cout << " + ";
		}
		cout << b[i];
		if(i != 0){
			cout << "x";
			if(i >= 2){
				cout << "^" << i;
			}
		}
	}
	cout << ")" << endl;
	return;
}

// main -----------------------------------------------

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n+1), b(n+1);
	REP(i, n+1){
		cin >> a[i];
	}
	REP(i, n+1){
		cin >> b[i];
	}

	// print(a, b);

	vector<ll> c(2*n+1);
	REP(i, n+1){
		REP(j, n+1){
			c[i+j] += a[i]*b[j]%MOD;
			c[i+j] %= MOD;
		}
	}

	ll sum = 0;
	REP(i, n+1){
		sum += c[i];
		sum %= MOD;
		// cout << c[i] << endl;
	}

	cout << sum << endl;
	return 0;
}
0