#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define G 3
inline int read()
{
char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
if(nega==-1) return -ans;
return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1uLL*x*y%mod;}
int qpow(int x,int y)
{
int ans=1;
while(y)
{
if(y&1) ans=mul(ans,x);
x=mul(x,x);
y>>=1;
}
return ans;
}
int Inv(int x)
{
return qpow(x,mod-2);
}
namespace Poly
{
vector<int> rev,rt,one(1,1);
vector<int> operator + (vector<int> a,vector<int> b)
{
int n=max(a.size(),b.size());
a.resize(n),b.resize(n);
for(int i=0;i<n;i++) a[i]=add(a[i],b[i]);
return a;
}
vector<int> operator - (vector<int> a,vector<int> b)
{
int n=max(a.size(),b.size());
a.resize(n),b.resize(n);
for(int i=0;i<n;i++) a[i]=sub(a[i],b[i]);
return a;
}
void init(int B)
{
int n=1<<B;
rev.resize(n),rt.resize(n);
for(int i=1;i<n;i++) rev[i]=(rev[i>>1]>>1)|((i&1)<<(B-1));
for(int mid=1;mid<n;mid<<=1)
{
int w=qpow(G,(mod-1)/(mid<<1));
rt[mid]=1;
for(int i=1;i<=mid;i++) rt[mid+i]=mul(rt[mid+i-1],w);
}
}
void NTT(vector<int> &a,int B)
{
int n=1<<B;
for(int i=0;i<n;i++) if(rev[i]>i) swap(a[i],a[rev[i]]);
for(int mid=1;mid<n;mid<<=1)
{
for(int i=0;i<n;i+=(mid<<1))
{
for(int j=0;j<mid;j++)
{
int x=a[i+j],y=mul(a[i+j+mid],rt[j+mid]);
a[i+j]=add(x,y),a[i+j+mid]=sub(x,y);
}
}
}
}
vector<int> operator * (vector<int> a,vector<int> b)
{
int B=0,n=a.size()+b.size()-1;
while((1<<B)<n) B++;
a.resize(1<<B),b.resize(1<<B);
init(B);
NTT(a,B),NTT(b,B);
for(int i=0;i<(1<<B);i++) a[i]=mul(a[i],b[i]);
reverse(a.begin()+1,a.end());
NTT(a,B);
a.resize(n);
int In=Inv(1<<B);
for(int i=0;i<n;i++) a[i]=mul(a[i],In);
return a;
}
};
using Poly::operator *;
signed main()
{
vector<int> a,b;
a.resize(read()+1),b.resize(read()+1);
for(int i=0;i<(int)a.size();i++) a[i]=read();
for(int i=0;i<(int)b.size();i++) b[i]=read();
a=a*b;
for(int i=0;i<(int)a.size();i++) printf("%d ",a[i]);
cout<<"\n";
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 37.83 us | 36 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 50.718 ms | 6 MB + 1004 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #3 | 23.116 ms | 3 MB + 80 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #4 | 23.184 ms | 3 MB + 68 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 38.4 us | 36 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 37.89 us | 36 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 36.8 us | 36 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 45.463 ms | 6 MB + 468 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 45.437 ms | 6 MB + 468 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 40.301 ms | 5 MB + 952 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 51.034 ms | 7 MB + 60 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 51.549 ms | 5 MB + 964 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 36.25 us | 36 KB | Accepted | Score: 0 | 显示更多 |