QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#126390#621. 多项式指数函数c20231020#80 450ms34444kbC++239.8kb2023-07-18 14:35:102023-07-18 14:35:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-18 14:35:12]
  • 评测
  • 测评结果:80
  • 用时:450ms
  • 内存:34444kb
  • [2023-07-18 14:35:10]
  • 提交

answer

/*
膜拜传奇特级宗师 Afterglow 大神儿
今天在 florr 首页称您为大夏尊贵的大名儿
一股敬佩之情油生然而
您在 florr 为国争光,扬我大夏威名
向您献上最真挚的膜拜!!!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
*/
/*
          _____                    _____                     _____                    _____
         /\    \                  /\    \                   /\    \                  /\    \
        /  \    \                /  \    \                 /  \____\                /  \    \
        \   \    \              /    \    \               /   /    /                \   \    \
         \   \    \            /      \    \             /   /    /                  \   \    \
          \   \    \          /   /\   \    \           /   /____/                    \   \    \
           \   \    \        /   /  \   \    \         /    |    |                     \   \    \
            \   \    \      /   /    \   \    \       /     |    |                      \   \    \
             \   \    \    /   /    / \   \    \     /      |    |                       \   \    \
              \   \    \  /   /    /   \   \    \   /       |____|__ _____                \   \    \
_______________\   \____\/   /____/     \   \    \ /   /|            \    \ _______________\   \____\
\                  /    /\   \    \      \   \    \\  / |    _________\____\\                  /    /
 \    ____________/____/  \   \    \      \   \____\\/__|   |    |           \    ____________/____/
  \   \    \               \   \    \     |   |    |    |   |    |            \   \    \
   \   \    \               \   \    \    |   |    |    |   |    |             \   \    \
    \   \    \               \   \    \   |   |____|    |   |    |              \   \    \
     \   \    \               \   \    \  /   /    /    \   |    |               \   \    \
      \   \    \               \   \    \/   /    /      \  |    |                \   \    \
       \   \____\               \   \___/   /    /        \ |    |                 \   \____\
        \  /    /                \         /    /          \|    |                  \  /    /
         \/____/                  \_______/____/            \____|                   \/____/
*/
#define poj
#define zcz
#ifdef poj
//C++
#include<iomanip>
#include<iostream>
//C
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
//STL
#include<algorithm>
#include<bitset>
#include<functional>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
//C++11
#if __cplusplus>=201103L
#include<chrono>
#include<random>
#include<unordered_set>
#include<unordered_map>
#endif
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#ifdef zcz
class fastin{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *inf;
	char *inbuf,*inst,*ined;
	inline char _getchar(){
		if(inst==ined)inst=inbuf,ined=inbuf+fread(inbuf,1,MAXBF,inf);
		return inst==ined?EOF:*inst++;
	}
	public:
	fastin(FILE*_inf=stdin){
		inbuf=new char[MAXBF],inf=_inf,inst=inbuf,ined=inbuf;
	}
	~fastin(){delete inbuf;}
	template<typename Int> fastin&operator>>(Int &n){
		static char c;
		Int t=1;
		while((c=_getchar())<'0'||c>'9')if(c=='-')t=-1;
		n=(c^48);
		while((c=_getchar())>='0'&&c<='9')n=n*10+(c^48);
		n*=t;
		return *this;
	}
	fastin&operator>>(char&c){
		while((c=_getchar())<'!'||c>'~');
		return *this;
	}
	fastin&operator>>(char*s){
		int t=0;
		static char c;
		while((c=_getchar())==' '||c=='\n');
		s[t++]=c;
		while((c=_getchar())>='!'&&c<='~')s[t++]=c;
		s[t]='\0';
		return *this;
	}
}fi;
class fastout{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *ouf;
	char *oubuf,*oust,*oued;
	inline void _flush(){fwrite(oubuf,1,oued-oust,ouf);oued=oust;}
	inline void _putchar(char c){
		if(oued==oust+MAXBF)_flush(),oued=oubuf;
		*oued++=c;
		#ifdef local
		_flush();
		#endif
	}
	public:
	fastout(FILE*_ouf=stdout){
		oubuf=new char[MAXBF],ouf=_ouf,oust=oubuf,oued=oubuf;
	}
	~fastout(){_flush();delete oubuf;}
	template<typename Int> fastout&operator<<(Int n){
		if(n<0)_putchar('-'),n=-n;
		static char S[20];
		int t=0;
		do{S[t++]='0'+n%10,n/=10;}while(n);
		for(int i=0;i<t;++i)_putchar(S[t-i-1]);
		return *this;
	}
	fastout&operator<<(char c){_putchar(c);return *this;}
	fastout&operator<<(char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
	fastout&operator<<(const char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
}fo;
#define cin fi
#define cout fo
#else
#define czc ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#endif
#define mod7 1000000007
#define mod9 998244353
#define ll long long
#define isinf 0x3f3f3f3f
#define ilinf 0x7fffffff
#define lsinf 0x3f3f3f3f3f3f3f3f
#define llinf 0x7fffffffffffffff
#define pii pair<int,int>
#define fr first
#define sc second
#define next ___
#define pb push_back
#define N 400010
#define M 5000010
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b,c) for(int i=(a);i<=(b);i+=c)
#define Per(i,a,b,c) for(int i=(a);i>=(b);i-=c)
#define Gra(i) for(int i=h[x];i;i=next[i])
typedef int arr[N];
typedef int arm[M];
typedef ll arl[N];
typedef ll alm[M];
typedef double ard[N];
typedef double adm[M];
namespace modint{
	template<typename Int,Int mod,Int m1>
	struct modint{
		Int v;
		modint(){v=0;}
		modint(Int a){v=a;}
		bool operator==(modint a){return v==a.v;}
		bool operator!=(modint a){return v!=a.v;}
		bool operator<(modint a){return v<a.v;}
		bool operator>(modint a){return v>a.v;}
		bool operator<=(modint a){return v<=a.v;}
		bool operator>=(modint a){return v>=a.v;}
		bool operator==(Int a){return v==a;}
		bool operator!=(Int a){return v!=a;}
		bool operator<(Int a){return v<a;}
		bool operator>(Int a){return v>a;}
		bool operator<=(Int a){return v<=a;}
		bool operator>=(Int a){return v>=a;}
		modint operator+(modint a){return v>=mod-a.v?v-mod+a.v:v+a.v;}
		friend modint operator+(Int x,modint a){return x>=mod-a.v?x-mod+a.v:x+a.v;}
		modint operator-(modint a){return v>=a.v?v-a.v:v+mod-a.v;}
		friend modint operator-(Int x,modint a){return x>=a.v?x-a.v:x+mod-a.v;}
		modint modnum(modint a){
			return a-((__int128(a.v)*m1)>>80)*mod;
		}
		modint operator*(modint a){return modnum(v*a.v);}
		modint operator+=(modint a){*this=*this+a;return *this;}
		modint operator-=(modint a){*this=*this-a;return *this;}
		modint operator*=(modint a){*this=*this*a;return *this;}
		modint qpow(modint a,Int b){
			modint r(1);
			for(;b;b>>=1,a*=a)if(b&1)r*=a;
			return r;
		}
		modint operator/(modint a){return qpow(a,mod-2)*v;}
		modint operator/=(modint a){*this=*this/a;return *this;}
		modint operator/(Int x){return qpow(modint(x),mod-2)*v;}
		friend modint operator/(Int x,modint a){return modint(x)/a;}
		modint&operator++(){*this=*this+1;return *this;}
		modint&operator--(){*this=*this-1;return *this;}
		const modint operator++(int){modint r=*this;++*this;return r;}
		const modint operator--(int){modint r=*this;--*this;return r;}
		#ifdef cout
		friend fastin&operator>>(fastin&in,modint&n){in>>n.v;return in;}
		friend fastout&operator<<(fastout&out,modint n){out<<n.v;return out;}
		#else
		friend istream&operator>>(istream&in,modint&n){in>>n.v;return in;}
		friend ostream&operator<<(ostream&out,modint n){out<<n.v;return out;}
		#endif
	};
	typedef modint<long long,1000000007,1208925811152148> int7;
	typedef modint<long long,998244353,1211051999424262> int9;
}
using namespace modint;
int r[N];
int9 w[N];
void ntt(int9*a,int t,int lim){
	int9 in=int9(1)/lim;
	for(int i=0;i<lim;++i)if(i<r[i])swap(a[i],a[r[i]]);
	w[0]=1;
	for(int mid=1;mid<lim;mid<<=1){
		int9 wn=wn.qpow(3,(mod9-1)/(mid*2));
		if(t==-1)wn=int9(1)/wn;
		for(int i=1;i<mid;++i)w[i]=w[i-1]*wn;
		for(int len=mid<<1,p=0;p<lim;p+=len){
			for(int i=p;i<mid+p;++i){
				int9 x=a[i],y=w[i-p]*a[mid+i];
				a[i]=x+y,a[mid+i]=x-y;
			}
		}
	}
	if(t==-1)for(int i=0;i<lim;++i)a[i]*=in;
}
int9 tem[N];
void div(int num,int9*a,int9*b){
	if(num==1){
		b[0]=int9(1)/a[0];
		return;
	}
	div((num+1)>>1,a,b);
	int lim=1,l=0;
	while(lim<(num<<1))lim<<=1,++l;
	for(int i=0;i<lim;++i)r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	For(i,0,num-1)tem[i]=a[i];
	fill(tem+num,tem+lim,0);
	ntt(tem,1,lim);ntt(b,1,lim);
	For(i,0,lim-1){
		b[i]*=2-b[i]*tem[i];
	}
	ntt(b,-1,lim);
	fill(b+num,b+lim,0);
}
void dev(int num,int9*a,int9*b){
	For(i,1,num-1)b[i-1]=a[i]*i;
	b[num-1]=0;
}
void indev(int num,int9*a,int9*b){
	For(i,1,num-1)b[i]=a[i-1]/int9(i);
	b[0]=0;
}
void ln(int num,int9*a,int9*b,int9*c,int9*d){
	fill(b,b+(num<<2),0);
	fill(b,c+(num<<2),0);
	fill(b,d+(num<<2),0);
	dev(num,a,c);
	div(num,a,d);
	int lim=1,l=0;
	while(lim<(num<<1))lim<<=1,++l;
	for(int i=0;i<lim;++i)r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	ntt(c,1,lim);ntt(d,1,lim);
	For(i,0,lim-1)c[i]*=d[i];
	ntt(c,-1,lim);
	indev(num,c,b);
}
int9 s[N],t[N],lt[N];
void exp(int num,int9*a,int9*b){
	if(num==1){
		b[0]=1;
		return;
	}
	exp((num+1)>>1,a,b);
	ln(num,b,lt,s,t);
	int lim=1,l=0;
	while(lim<(num<<1))lim<<=1,++l;
	for(int i=0;i<lim;++i)r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	For(i,0,num-1)lt[i]=a[i]-lt[i];
	lt[0]++;
	fill(lt+num,lt+lim,0);
	fill(b+num,b+lim,0);
	ntt(b,1,lim);ntt(lt,1,lim);
	For(i,0,lim-1)b[i]*=lt[i];
	ntt(b,-1,lim);
	fill(b+num,b+lim,0);
}
int n,m;
int9 f[N],g[N],a[N],b[N];
void solve(){
	cin>>n;
	For(i,0,n-1)cin>>f[i];
	exp(n,f,g);
	For(i,0,n-1)cout<<g[i]<<' ';
	cout<<'\n';
	return;
}
int main(){
	#ifndef zcz
	czc;
	#endif
	int t=1;
	while(t--)solve();
	return 0;
}

详细

Test #1:

score: 20
Accepted
time: 3ms
memory: 31668kb

input:

100
0 158447743 737554986 671332600 489297184 754299210 115728600 816221630 819073359 691660913 910093246 562505672 355119917 385019894 611338034 123976316 122342952 82142434 796101450 994778874 575255638 493217967 652609142 662045597 783871340 470398790 241710709 754059035 534582325 836438174 95789...

output:

1 158447743 989903074 918187254 200068193 455062373 11196740 759336019 312075964 992242039 123230223 144998958 189062409 420150911 170942299 432890803 760087114 639614944 787205333 63667632 243571846 141993017 450288335 173318832 743144111 879389773 95666186 453410000 569486107 512729334 226210545 5...

result:

ok 100 numbers

Test #2:

score: 20
Accepted
time: 24ms
memory: 31804kb

input:

5000
0 354399910 26360255 630255958 717224815 366941345 333979504 905420494 38176634 475666562 611197455 433060682 509600868 845217181 520468365 529689763 431747498 192834976 685184103 287994809 273221518 522219732 427553800 10872482 525061651 448069946 183539744 610476003 840167561 241104955 404100...

output:

1 354399910 51676417 184411965 928033808 589971658 936383703 745898312 943454394 65252947 270867254 772620225 995104944 58521883 96491645 326592384 283913887 140742590 960115688 684602174 623426872 184484323 952879775 315489867 167038509 580362327 164714100 833258994 345402076 261957154 469710461 98...

result:

ok 5000 numbers

Test #3:

score: 20
Accepted
time: 106ms
memory: 31864kb

input:

30000
0 147199510 293972908 780683378 633744119 800282266 162025013 919460711 939176222 298044997 277962122 729446209 455723129 756791462 84697115 579989768 945113433 549318980 229266945 869577376 103161009 960973464 440149102 836285074 687333626 638404974 184096947 370164754 454531549 142629528 150...

output:

1 147199510 30930552 734023222 564008583 299902819 450980389 806779390 654937901 981162061 206882721 35851319 707998765 357594654 305814262 734562024 591099032 543969413 539432668 154163976 451201740 856569012 898961429 732819402 243444529 673245321 601964526 206333661 876679409 438174247 903706710 ...

result:

ok 30000 numbers

Test #4:

score: 20
Accepted
time: 450ms
memory: 34444kb

input:

100000
0 279349013 196667718 617497154 78288698 996674429 180463729 304956112 173800460 352061138 224505321 119706982 726737325 564797383 757014824 888433954 747100108 723246918 645172013 184990722 321964667 456686646 138153830 701558524 317746193 650472945 49496183 864461799 982372868 582778782 242...

output:

1 279349013 426120005 205100346 421201310 474118168 879116053 749708347 23319122 872190753 903275287 797670709 327019687 707029564 46014243 838268797 28223150 48499086 927009654 52188573 200586020 4624185 827007182 201682326 552029133 820855946 97607062 601649418 37529652 24405665 116064030 62051631...

result:

ok 100000 numbers

Test #5:

score: 0
Memory Limit Exceeded

input:

1000000
0 204517192 162156394 729093416 352181074 335898409 357987855 386581690 26622360 437289663 34104646 938411413 659876244 293619518 291093969 909364118 179765868 89417259 632261731 375051702 493701794 771716785 682264158 329653513 86558030 9195128 957504298 22555222 384175297 128022431 5957444...

output:


result: