提交记录 8953


用户 题目 状态 得分 用时 内存 语言 代码长度
YeahPotato 1002i. 【模板题】多项式乘法 Accepted 100 77.382 ms 6700 KB C++ 1.30 KB
提交时间 评测时间
2019-03-26 17:45:02 2020-08-01 01:27:34
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define MOD 998244353
typedef long long ll;
const int N = 3e5+5;
int n, m, f[N], len = 1, lim;
ll a[N], b[N], Ilen;
inline int qpow(ll x, int y) {
	ll t = 1;
	while (y) {
		if (y & 1) t = t * x % MOD;
		x = x * x % MOD, y >>= 1;
	} return t;
}
inline int PLUS(int x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
	if (x < 0) x += MOD;
	return x;
}
void NTT(ll *a, int n, bool op) {
	for (int i=0; i<n; i++)
		if (i < f[i]) swap(a[i], a[f[i]]);
	for (int m=1; m<n; m<<=1) {
		ll omega = qpow(3, (MOD - 1) / (m << 1));
		for (int i=0; i<n; i+=m<<1) {
			ll x = 1;
			for (int j=0; j<m; j++, x=x*omega%MOD) {
				ll tmp = x * a[i + j + m] % MOD;
				a[i + j + m] = (a[i + j] - tmp + MOD) % MOD;
				a[i + j] = (a[i + j] + tmp) % MOD;
			}
		}
	}
	if (op) reverse (a+1, a+n);
}
int main() {
	cin >> n >> m;
	for (int i=0; i<=n; i++)
		scanf ("%lld", &a[i]);
	for (int i=0; i<=m; i++)
		scanf ("%lld", &b[i]);
	n += m;
	while (len <= n) ++lim, len <<= 1;
	Ilen = qpow(len, MOD - 2);
	for (int i=0; i<len; i++)
		f[i] = f[i >> 1] >> 1 | (i & 1) << lim - 1;
	NTT(a, len, 0), NTT(b, len, 0);
	for (int i=0; i<len; i++)
		a[i] = a[i] * b[i] % MOD;
	NTT(a, len, 1);
	for (int i=0; i<=n; i++)
		printf ("%lld ", a[i] * Ilen % MOD);
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Subtask #1 Testcase #137.91 us48 KBAcceptedScore: 0

Subtask #1 Testcase #276.43 ms6 MB + 476 KBAcceptedScore: 100

Subtask #1 Testcase #334.9 ms2 MB + 840 KBAcceptedScore: 0

Subtask #1 Testcase #434.956 ms2 MB + 828 KBAcceptedScore: 0

Subtask #1 Testcase #541.5 us48 KBAcceptedScore: 0

Subtask #1 Testcase #638.52 us48 KBAcceptedScore: 0

Subtask #1 Testcase #739.16 us48 KBAcceptedScore: 0

Subtask #1 Testcase #870.505 ms6 MB + 208 KBAcceptedScore: 0

Subtask #1 Testcase #970.703 ms6 MB + 208 KBAcceptedScore: 0

Subtask #1 Testcase #1064.892 ms5 MB + 964 KBAcceptedScore: 0

Subtask #1 Testcase #1176.762 ms6 MB + 556 KBAcceptedScore: 0

Subtask #1 Testcase #1277.382 ms5 MB + 436 KBAcceptedScore: 0

Subtask #1 Testcase #1337.54 us48 KBAcceptedScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-05 08:21:10 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠