提交记录 17497


用户 题目 状态 得分 用时 内存 语言 代码长度
Terrible_ 1002i. 【模板题】多项式乘法 Accepted 100 63.204 ms 10772 KB C++11 1.06 KB
提交时间 评测时间
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));
}

CompilationN/AN/ACompile OKScore: N/A

Subtask #1 Testcase #19.08 us24 KBAcceptedScore: 0

Subtask #1 Testcase #262.859 ms10 MB + 452 KBAcceptedScore: 0

Subtask #1 Testcase #328.387 ms4 MB + 816 KBAcceptedScore: 100

Subtask #1 Testcase #428.385 ms4 MB + 804 KBAcceptedScore: 0

Subtask #1 Testcase #510.43 us24 KBAcceptedScore: 0

Subtask #1 Testcase #69.07 us24 KBAcceptedScore: 0

Subtask #1 Testcase #79.25 us24 KBAcceptedScore: 0

Subtask #1 Testcase #857.314 ms10 MB + 184 KBAcceptedScore: 0

Subtask #1 Testcase #957.166 ms10 MB + 184 KBAcceptedScore: 0

Subtask #1 Testcase #1052.046 ms9 MB + 940 KBAcceptedScore: 0

Subtask #1 Testcase #1163.204 ms10 MB + 532 KBAcceptedScore: 0

Subtask #1 Testcase #1263.112 ms9 MB + 412 KBAcceptedScore: 0

Subtask #1 Testcase #138.25 us24 KBAcceptedScore: 0


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