提交记录 5431
提交时间 |
评测时间 |
2018-08-22 18:30:35 |
2020-08-01 00:17:07 |
// luogu-judger-enable-o2
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cctype>
using namespace std;
int read()
{
int x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
int n,m;
const long double PI=acos(-1.0);
struct Complex
{
long double x,y;
}a[4200000],b[4200000];
Complex operator + (Complex a,Complex b)
{
return {a.x+b.x,a.y+b.y};
}
Complex operator - (Complex a,Complex b)
{
return {a.x-b.x,a.y-b.y};
}
Complex operator * (Complex a,Complex b)
{
return {a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x};
}
int lim=1,l,r[4200000];
void FFT(Complex *A,int type)
{
for (int i=0;i<lim;i++)
if (i<r[i])
swap(A[i],A[r[i]]);
for (int mid=1;mid<lim;mid<<=1)
{
Complex Wn={cos(PI/mid),type*sin(PI/mid)};
for (int j=0;j<lim;j+=(mid<<1))
{
Complex W={1,0};
for (int k=0;k<mid;k++)
{
Complex x=A[j+k],y=W*A[j+mid+k];
A[j+k]=x+y;
A[j+mid+k]=x-y;
W=W*Wn;
}
}
}
}
int main()
{
n=read();m=read();
for (int i=0;i<=n;i++)
a[i].x=read();
for (int i=0;i<=m;i++)
b[i].x=read();
while (lim<=n+m)
{
lim<<=1;
l++;
}
for (int i=0;i<lim;i++)
r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
FFT(a,1);
FFT(b,1);
for (int i=0;i<=lim;i++)
a[i]=a[i]*b[i];
FFT(a,-1);
for (int i=0;i<=n+m;i++)
printf("%d ",(int)(a[i].x/lim+0.5));
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 8.85 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 115.611 ms | 18 MB + 456 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #3 | 50.716 ms | 8 MB + 820 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #4 | 50.153 ms | 8 MB + 808 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 10.06 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 9.3 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 9.13 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 110.286 ms | 18 MB + 188 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 110.05 ms | 18 MB + 188 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 104.729 ms | 17 MB + 944 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 115.859 ms | 18 MB + 536 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 115.979 ms | 17 MB + 416 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 7.8 us | 28 KB | Accepted | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-04-20 21:39:46 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用