QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#341428#618. 多项式乘法iorit#Compile Error//C++142.7kb2024-02-29 18:51:522024-02-29 18:51:54

Judging History

你现在查看的是最新测评结果

  • [2024-02-29 18:51:54]
  • 评测
  • [2024-02-29 18:51:52]
  • 提交

answer

#include <bits/stdc++.h>
#define LL long long
#define sl(n) strlen(n)
#define endline puts("")
#define pii pair<int , int>
#define pr_q priority_queue
#define debug puts("DEBUG.")
using namespace std;
const int N = (1 << 21) + 10;
const int inf = ~0u >> 2;
const int p = 998244353,g = 3,ginv = (p + 1) / 3;
namespace IO
{
	const int I=1<<20,O=11<<20;int l=0;char i[I|1],o[O|1],*n,*m;
	#ifdef ONLINE_JUDGE
	#define g (n==m?m=(n=i)+fread(i,1,I|1,stdin),(n==m?-1:*n++):*n++)
	#else
	#define g getchar()
	#endif
	inline int read(){int x=0,w=1;char c=g;while(c<48||c>57)c==45&&(w=-1),c=g;while(c>47&&c<58)x=x*10+c-48,c=g;return w==1?x:-x;}
	inline LL readl(){LL x=0,w=1;char c=g;while(c<48||c>57)c==45&&(w=-1),c=g;while(c>47&&c<58)x=x*10+c-48,c=g;return w==1?x:-x;}
	inline int readt(char *s){int l=0;char c=g;while(c==10||c==13||c==48)c=g;while(c!=10&&c!=13&&c!=48)s[l++]=c,c=g;return l;}
	inline string reads(){string s="";char c=g;while(c==10||c==13||c==48)c=g;while(c!=10&&c!=13&&c!=48)s+=c,c=g;return s;}
	inline char readc(){char c=g;while(c==10||c==13||c==48)c=g;return c;}inline void putc(char c){o[l++]=c;}
	template<class T>void write(T x){x<0&&(putc(45),x=-x),x>9&&(write(x/10),0),putc(x%10+48);}
	inline void flush(){fwrite(o,1,l,stdout);}
}
using IO::flush;using IO::putc;using IO::readt;using IO::readc;
using IO::readl;using IO::reads;using IO::read;using IO::write;
int qpow(int a , int k)
{
	int res = 1;
	while(k)
	{
		if(k & 1)
			res = 1ll * res * a % p;
		a = 1ll * a * a % p;
		k >>= 1;
	}
	return res;
}
inline int getmod(int x)
	{return x >= p ? x - p : x;}
int n,m,a[N],b[N],lim,rev[N];
void init(int n)
{
	int l = 0;
	lim = 1;
	while(lim < n)
		lim <<= 1,l++;
	for(int i = 0;i < lim;i++)
		rev[i] = (rev[i >> 1] >> 1) | ( (i & 1) << l - 1 );
}
void fft(int *f , int op)
{
	for(int i = 0;i < lim;i++)
		if(rev[i] < i)
			swap( f[ rev[i] ] , f[i] );
	for(int len = 1;len < lim;len <<= 1)
	{
		int w0 = qpow(op == 1 ? g : ginv , (p - 1) / (len * 2) );
		for(int i = 0;i < lim;i += 2 * len)
			for(int j = 0,wk = 1;j < len;j++,wk = 1ll * wk * w0 % p)
			{
				int x = f[i + j],y = 1ll * f[i + j + len] * wk % p;
				f[i + j] = getmod(x + y),f[i + j + len] = getmod(x - y + p);
			}
	}
	if(op == -1)
	{
		int inv = qpow(lim , p - 2);
		for(int i = 0;i < lim;i++)
			f[i] = 1ll * f[i] * inv % p;
	}
}
int main()
{
	n = read() + 1,m = read() + 1;
	for(int i = 0;i < n;i++)
		a[i] = read();
	for(int i = 0;i < m;i++)
		b[i] = read();
	init(n + m - 1);
	fft(a , 1),fft(b , 1);
	for(int i = 0;i < lim;i++)
		a[i] = 1ll * a[i] * b[i] % p;
	fft(a , -1);
	for(int i = 0;i < n + m - 1;i++)
		write( a[i] ),putc(' ');
	putc('\n');
	flush();
	return 0;
}

详细

answer.code: In function ‘void fft(int*, int)’:
answer.code:16:30: error: ‘i’ was not declared in this scope; did you mean ‘IO::i’?
   16 |         #define g (n==m?m=(n=i)+fread(i,1,I|1,stdin),(n==m?-1:*n++):*n++)
      |                              ^
answer.code:61:41: note: in expansion of macro ‘g’
   61 |                 int w0 = qpow(op == 1 ? g : ginv , (p - 1) / (len * 2) );
      |                                         ^
answer.code:14:49: note: ‘IO::i’ declared here
   14 |         const int I=1<<20,O=11<<20;int l=0;char i[I|1],o[O|1],*n,*m;
      |                                                 ^
answer.code:16:43: error: ‘I’ was not declared in this scope; did you mean ‘IO::I’?
   16 |         #define g (n==m?m=(n=i)+fread(i,1,I|1,stdin),(n==m?-1:*n++):*n++)
      |                                           ^
answer.code:61:41: note: in expansion of macro ‘g’
   61 |                 int w0 = qpow(op == 1 ? g : ginv , (p - 1) / (len * 2) );
      |                                         ^
answer.code:14:19: note: ‘IO::I’ declared here
   14 |         const int I=1<<20,O=11<<20;int l=0;char i[I|1],o[O|1],*n,*m;
      |                   ^
answer.code:16:63: error: invalid type argument of unary ‘*’ (have ‘int’)
   16 |         #define g (n==m?m=(n=i)+fread(i,1,I|1,stdin),(n==m?-1:*n++):*n++)
      |                                                               ^~~~
answer.code:61:41: note: in expansion of macro ‘g’
   61 |                 int w0 = qpow(op == 1 ? g : ginv , (p - 1) / (len * 2) );
      |                                         ^
answer.code:16:69: error: invalid type argument of unary ‘*’ (have ‘int’)
   16 |         #define g (n==m?m=(n=i)+fread(i,1,I|1,stdin),(n==m?-1:*n++):*n++)
      |                                                                     ^~~~
answer.code:61:41: note: in expansion of macro ‘g’
   61 |                 int w0 = qpow(op == 1 ? g : ginv , (p - 1) / (len * 2) );
      |                                         ^