結果

問題 No.2272 多項式乗算 mod 258280327
ユーザー 沙耶花沙耶花
提出日時 2023-04-14 22:00:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,675 bytes
コンパイル時間 4,895 ms
コンパイル使用メモリ 265,084 KB
実行使用メモリ 26,188 KB
最終ジャッジ日時 2024-04-18 19:25:02
合計ジャッジ時間 8,823 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 20 ms
5,376 KB
testcase_26 AC 20 ms
5,376 KB
testcase_27 AC 43 ms
6,420 KB
testcase_28 AC 42 ms
6,512 KB
testcase_29 AC 241 ms
14,732 KB
testcase_30 AC 489 ms
26,040 KB
testcase_31 AC 471 ms
26,188 KB
testcase_32 AC 500 ms
26,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

template <class T>
vector<T> convolution_mint(vector<T> a,vector<T> b){
	
	static constexpr unsigned long long M0 = 998244353;
	static constexpr unsigned long long M1 = 754974721;
	static constexpr unsigned long long M2 = 469762049;
	
	vector<long long> aa(a.size()),bb(b.size());
	rep(i,a.size())aa[i] = a[i].val();
	rep(i,b.size())bb[i] = b[i].val();
	
	auto c0 = convolution<M0>(aa,bb);
	auto c1 = convolution<M1>(aa,bb);
	auto c2 = convolution<M2>(aa,bb);
	
	vector<mint> ret(c0.size());
	
	rep(i,c0.size()){		
		
		ret[i] += c0[i];
		
		{
			long long cur = c0[i];
			cur %= M1;
			cur = c1[i]-cur;
			if(cur<0)cur += M1;
			cur *= 416537774;
			cur %= M1;
			
			mint m = M0;
			ret[i] += m*cur;
			
			cur *= M0;
			cur += c0[i];
			cur %= M2;
			cur = c2[i] - cur;
			if(cur<0)cur += M2;
			cur *= 429847628;
			cur %= M2;
			m *= M1;
			ret[i] += m * cur;
		}
	}
	
	return ret;
}

int main(){
	mint::set_mod(258280327);
	
	int N,M;
	cin>>N;
	vector<mint> a(N+1);
	rep(i,N+1){
		long long t;
		cin>>t;
		a[i] = t;
	}
	cin>>M;
	vector<mint> b(M+1);
	rep(i,M+1){
		long long t;
		cin>>t;
		b[i] = t;
	}
	a = convolution_mint(a,b);
	while(a.size()>1 && a.back()==0)a.pop_back();
	cout<<a.size()-1<<endl;
	rep(i,a.size()){
		if(i!=0)cout<<' ';
		cout<<a[i].val();
	}
	cout<<endl;
	
	/*
	long long N,E;
	cin>>N>>E;
	
	if(N>=0){
		long long sq = sqrtl(N);
		if(sq*sq==N){
			cout<<sq<<endl;
			return 0;
		}
	}
	*/
	
	
	return 0;
}
0