提交记录 17497
提交时间 |
评测时间 |
2022-03-20 16:23:11 |
2022-03-20 16:23:15 |
#include<cstdio>
#include<complex>
#include<algorithm>
typedef std::complex<double> cd;
int read()
{
int a=0;char c;
while((c=getchar())<'0');
while(c>='0')a=a*10+(c^48),c=getchar();
return a;
}
const double pi=acos(-1);
class _FFT
{
private:
int r[2097152],lim;
public:
void init(const int l)
{
lim=1<<l;const int l_=l-1;
for(int i=0;i<lim;i++)r[i]=r[i/2]/2|(i&1)<<l_;
}
void operator()(cd*a,const int type)
{
for(int i=0;i<lim;i++)if(r[i]>i)std::swap(a[i],a[r[i]]);
for(int mid=1;mid<lim;mid<<=1)
{
cd omega1(cos(pi/mid),type*sin(pi/mid));
const int step=mid*2;
for(int j=0;j<lim;j+=step)
{
cd omega=1;
for(int k=0;k<mid;k++,omega*=omega1)
{
cd x=a[j+k],y=omega*a[j+mid+k];
a[j+k]=x+y,a[j+mid+k]=x-y;
}
}
}
}
}FFT;
cd a[2097152],b[2097152];
int main()
{
int n=read(),m=read(),l=32-__builtin_clz(n+m),lim=1<<l;FFT.init(l);
for(int i=0;i<=n;i++)a[i]=read();FFT(a,1);
for(int i=0;i<=m;i++)b[i]=read();FFT(b,1);
for(int i=0;i<lim;i++)a[i]*=b[i];FFT(a,-1);
for(int i=0;i<=n+m;i++)printf("%d ",int(a[i].real()/lim+0.5));
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 9.08 us | 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 62.859 ms | 10 MB + 452 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #3 | 28.387 ms | 4 MB + 816 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #4 | 28.385 ms | 4 MB + 804 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 10.43 us | 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 9.07 us | 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 9.25 us | 24 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 57.314 ms | 10 MB + 184 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 57.166 ms | 10 MB + 184 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 52.046 ms | 9 MB + 940 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 63.204 ms | 10 MB + 532 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 63.112 ms | 9 MB + 412 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 8.25 us | 24 KB | Accepted | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:21:59 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠