提交记录 6545
提交时间 |
评测时间 |
2018-10-25 15:57:11 |
2020-08-01 00:45:42 |
#include<bits/stdc++.h>
#define N 262145
#define pi acos(-1)
using namespace std;
typedef complex<double> E;
int n,m,l,r[N];
E a[N],b[N];
void FFT(E *a,int f){
for(int i=0;i<n;i++)if(i<r[i])swap(a[i],a[r[i]]);
for(int i=1;i<n;i<<=1){
E wn(cos(pi/i),f*sin(pi/i));
for(int p=i<<1,j=0;j<n;j+=p){
E w(1,0);
for(int k=0;k<i;k++,w*=wn){
E x=a[j+k],y=w*a[j+k+i];
a[j+k]=x+y;a[j+k+i]=x-y;
}
}
}
}
inline int read(){
int f=1,x=0;char ch;
do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
return f*x;
}
int main(){
n=read();m=read();
for(int i=0;i<=n;i++)a[i]=read();
for(int i=0;i<=m;i++)b[i]=read();
m+=n;for(n=1;n<=m;n<<=1)l++;
for(int i=0;i<n;i++)r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
FFT(a,1);FFT(b,1);
for(int i=0;i<=n;i++)a[i]=a[i]*b[i];
FFT(a,-1);
for(int i=0;i<=m;i++)printf("%d ",(int)(a[i].real()/n+0.5));
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Subtask #1 Testcase #1 | 36.21 us | 48 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #2 | 63.213 ms | 10 MB + 464 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #3 | 28.73 ms | 4 MB + 840 KB | Accepted | Score: 100 | 显示更多 |
Subtask #1 Testcase #4 | 28.768 ms | 4 MB + 828 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #5 | 38.05 us | 48 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #6 | 37.59 us | 48 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #7 | 36.67 us | 48 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #8 | 57.851 ms | 10 MB + 196 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #9 | 57.779 ms | 10 MB + 196 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #10 | 52.512 ms | 9 MB + 952 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #11 | 63.536 ms | 10 MB + 544 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #12 | 63.94 ms | 9 MB + 424 KB | Accepted | Score: 0 | 显示更多 |
Subtask #1 Testcase #13 | 34.75 us | 48 KB | Accepted | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:15:59 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠