提交记录 17047


用户 题目 状态 得分 用时 内存 语言 代码长度
cyf 1002i. 【模板题】多项式乘法 Time Limit Exceeded 0 1 s 4408 KB C++11 2.04 KB
提交时间 评测时间
2021-11-30 18:12:38 2021-11-30 18:12:45
#include <bits/stdc++.h>
#define maxn 500005
#define mod 998244353
#define LL long long
using namespace std;
int Wl,Wl2,w[maxn];
inline int Pow(int b, int k) { int r=1; for(;k;k>>=1,b=1ll*b*b%mod) if(k&1) r=1ll*r*b%mod; return r; }
inline void init(int n) {
	for(Wl=1;n>=Wl<<1;Wl<<=1); int pw=Pow(3,(mod-1)/(Wl2=Wl<<1)); w[Wl]=1;
	for(int i=Wl+1;i<=Wl2;i++) w[i]=w[i-1]*1ll*pw%mod; for(int i=Wl-1;i>=1;i--) w[i]=w[i<<1];
}
inline int upd(int x) { return x+=x>>31&mod; }
inline void NTT(int *A, int bit, int tp) {
	static int r[maxn]={}; static unsigned LL ar[maxn]={};
	int n=1<<bit; if(tp^1) reverse(A+1,A+n);
	for(int i=0;i<n;i++) r[i]=(r[i>>1]>>1|(i&1)<<bit-1),ar[i]=upd(A[r[i]]);
	for(int L=1;L<n;L<<=1) for(int s=0,L2=L<<1;s<n;s+=L2)
	for(int k=s,x=L,t;x<L2;x++,k++) t=ar[k+L]*w[x]%mod,ar[k+L]=ar[k]-t+mod,ar[k]+=t;
	for(int i=0;i<n;i++) A[i]=ar[i]%mod;
	if(tp^1) for(int i=0,iv=Pow(n,mod-2);i<n;i++) A[i]=1ll*A[i]*iv%mod;
}
inline int Init(int n) { int m; for(m=1;m<=n;m<<=1); init(m); return m; }
namespace IO {
	inline char nc(){
		static char buf[500005],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,500000,stdin),p1==p2)?EOF:*p1++;
	}
	char out[500005],*pout=out,*eout=out+500000;
	inline void flush() { fwrite(out,1,pout-out,stdout),pout=out; }
	inline void pc(char c) { pout==eout&&(fwrite(out,1,500000,stdout),pout=out); (*pout++)=c; }
	template<typename T> inline void put(T x,char suf) {
		static char stk[40];int top=0; while(x) stk[top++]=x%10,x/=10;
		!top?pc('0'),0:0; while(top--) pc(stk[top]+'0'); pc(suf);
	}
	inline int read(){
		char ch=nc(); int sum=0; for(;ch<'0'||ch>'9';ch=nc());
		while(ch>='0'&&ch<='9')sum=(sum<<1)+(sum<<3)+ch-48,ch=nc();
		return sum;
	}
}
#define Rint IO::read()
using IO::put;
int n,m,A[maxn],B[maxn];
int main() { // freopen("input","r",stdin);
	n=Rint+1;m=Rint+1; Init(n+m);
	for(int i=0;i<n;i++) A[i]=Rint; for(int i=0;i<m;i++) B[i]=Rint;
	int N=n+m-1,M=1; while((1<<M)<=N) M++; NTT(A,M,1); NTT(B,M,1);
	for(int i=0;i<(1<<M);i++) A[i]=1ll*A[i]*B[i]%mod; NTT(A,M,-1);
	for(int i=0;i<N;i++) put(A[i],' '); IO::flush();
}

CompilationN/AN/ACompile OKScore: N/A

Subtask #1 Testcase #135.47 us68 KBAcceptedScore: 0

Subtask #1 Testcase #21 s2 MB + 964 KBTime Limit ExceededScore: -100

Subtask #1 Testcase #38.241 ms4 MB + 312 KBAcceptedScore: 100

Subtask #1 Testcase #48.272 ms4 MB + 288 KBAcceptedScore: 0

Subtask #1 Testcase #536.45 us68 KBAcceptedScore: 0

Subtask #1 Testcase #634.6 us68 KBAcceptedScore: 0

Subtask #1 Testcase #734.83 us68 KBAcceptedScore: 0

Subtask #1 Testcase #81 s2 MB + 764 KBTime Limit ExceededScore: 0

Subtask #1 Testcase #91 s2 MB + 764 KBTime Limit ExceededScore: 0

Subtask #1 Testcase #101 s2 MB + 560 KBTime Limit ExceededScore: 0

Subtask #1 Testcase #111 s2 MB + 964 KBTime Limit ExceededScore: 0

Subtask #1 Testcase #121 s2 MB + 964 KBTime Limit ExceededScore: 0

Subtask #1 Testcase #1336.01 us64 KBAcceptedScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-03-18 05:36:11 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠