QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#261851#7761. 物理实验zhouhuanyi30 2579ms104944kbC++142.9kb2023-11-23 11:56:322023-11-23 11:56:34

Judging History

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

  • [2023-11-23 11:56:34]
  • 评测
  • 测评结果:30
  • 用时:2579ms
  • 内存:104944kb
  • [2023-11-23 11:56:32]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 200000
#define K 524288
#define M 20
#define g 3
#define mod 998244353
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
void Adder(int &x,int d)
{
	x+=d;
	if (x>=mod) x-=mod;
	return;
}
void Adder2(int &x,int d)
{
	x+=d;
	if (x<0) x+=mod;
	return;
}
int MD(int x)
{
	return x>=mod?x-mod:x;
}
int MD2(int x)
{
	return x<0?x+mod:x;
}
int fast_pow(int a,int b)
{
	int res=1,mul=a;
	while (b)
	{
		if (b&1) res=1ll*res*mul%mod;
		mul=1ll*mul*mul%mod,b>>=1;
	}
	return res;
}
int n,m,length,p,L,R,res,cnt[N+1],rev[K+1],wn[M+1][K+1],wn2[M+1][K+1],A[K+1],B[K+1],num[K+1];
void NTT(int limit,int *s,int type)
{
	int s1,s2;
	for (int i=1;i<limit;++i) rev[i]=(rev[i>>1]>>1)|((i&1)?(limit>>1):0);
	for (int i=0;i<limit;++i)
		if (rev[i]>i)
			swap(s[i],s[rev[i]]);
	if (type==1)
	{
		for (int i=2;i<=limit;i<<=1)
			for (int j=0;j+i-1<limit;j+=i)
				for (int k=j;k<j+(i>>1);++k)
					s1=s[k],s2=1ll*s[k+(i>>1)]*wn[num[i]][k-j]%mod,s[k]=MD(s1+s2),s[k+(i>>1)]=MD2(s1-s2);
	}
	else
	{
		for (int i=2;i<=limit;i<<=1)
			for (int j=0;j+i-1<limit;j+=i)
				for (int k=j;k<j+(i>>1);++k)
					s1=s[k],s2=1ll*s[k+(i>>1)]*wn2[num[i]][k-j]%mod,s[k]=MD(s1+s2),s[k+(i>>1)]=MD2(s1-s2);
		for (int i=0;i<limit;++i) s[i]=1ll*s[i]*fast_pow(limit,mod-2)%mod;
	}
	return;
}
struct reads
{
	int d[N+1];
};
reads e,nw,nws,c,zero;
reads operator * (reads a,reads b)
{
	c=zero;
	int limit=1;
	while (limit<=(m<<2)) limit<<=1;
	for (int i=0;i<=limit;++i) A[i]=B[i]=0;
	for (int i=0;i<(m<<1);++i) A[i]=a.d[i],B[i]=b.d[i];
	NTT(limit,A,1),NTT(limit,B,1);
	for (int i=0;i<=limit;++i) A[i]=1ll*A[i]*B[i]%mod;
	NTT(limit,A,-1);
	for (int i=0;i<(m<<2);++i) Adder(c.d[i%(m<<1)],A[i]);
	return c;
}
reads fast_pow(reads a,int b)
{
	reads res=e,mul=a;
	while (b)
	{
		if (b&1) res=res*mul;
		mul=mul*mul,b>>=1;
	}
	return res;
}
int main()
{
	reads dst;
	int x,rst,limit=1;
	for (int i=2;i<=K;i<<=1)
	{
		num[i]=++length,rst=fast_pow(g,(mod-1)/i);
		for (int j=0,res=1;j<i;++j,res=1ll*res*rst%mod) wn[num[i]][j]=res;
		rst=fast_pow(g,(mod-1)/i*(i-1));
		for (int j=0,res=1;j<i;++j,res=1ll*res*rst%mod) wn2[num[i]][j]=res;
	}
	n=read(),m=read(),p=read(),L=read(),R=read(),e.d[0]=1,nw.d[1]=nw.d[(m<<1)-1]=1ll*p*MD2(1-p)%mod,nw.d[0]=MD(1ll*p*p%mod+1ll*MD2(1-p)*MD2(1-p)%mod);
	for (int i=1;i<=n;++i) x=read(),cnt[x]++;
	while (limit<=(m<<1)) limit<<=1;
	for (int i=0;i<m;++i) A[i]=cnt[i],B[m-i]=cnt[i];
	NTT(limit,A,1),NTT(limit,B,1);
	for (int i=0;i<=limit;++i) A[i]=1ll*A[i]*B[i]%mod;
	NTT(limit,A,-1);
	for (int i=1;i<m;++i) nws.d[i]=A[m+i];
	dst=nws*fast_pow(nw,L-1);
	for (int i=L;i<=R;++i)
	{
		dst=dst*nw,res=0;
		for (int j=1;j<m;++j) Adder(res,1ll*dst.d[j]*min(j,m-j)%mod),Adder2(res,-1ll*dst.d[j+m]*min(j,m-j)%mod);
		printf("%d ",res);
	}
	puts("");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

7500 7500 96132844 1 7500
1791 817 5559 4742 5272 3988 6672 1355 2783 5552 6885 5321 5996 6495 3072 2241 5527 856 6250 2741 4223 1560 6529 5330 3517 2637 6577 244 1739 5147 2648 6466 1479 7340 7355 176 183 1417 2943 5134 3879 3574 734 4880 7451 3778 1466 5237 2015 1334 6105 4859 1331 5805 3175 4795 ...

output:

107146521 488242901 833543364 942893118 320285439 306745340 85380418 480027337 540734953 491950738 458848527 302817505 548924517 963679504 322777659 657420416 538451400 200569821 907146642 940780727 947566362 523285833 942400409 151786157 800926749 797312944 150412848 483203343 637066163 296999542 7...

result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 10
Accepted

Test #5:

score: 10
Accepted
time: 332ms
memory: 101168kb

input:

100000 7500 500440646 935892941 935892941
3280 7218 1216 489 4036 7029 5538 4805 2544 568 4303 816 739 2284 1294 6062 808 3029 3565 4344 7124 3917 705 3637 6076 2019 4233 2032 7327 5672 2872 2593 22 1534 2071 5782 3228 5460 1217 5138 7285 3679 2751 213 2242 2673 2746 7041 7001 860 2591 7347 3330 213...

output:

768801558 

result:

ok 1 number(s): "768801558"

Test #6:

score: 0
Accepted
time: 334ms
memory: 100824kb

input:

100000 7499 356847081 883948227 883948227
549 2423 3380 3811 4666 3645 5857 7184 7137 861 2619 519 409 1607 2298 7164 2216 2856 6790 6857 405 1928 5391 2949 6345 4839 2372 2974 4699 2688 6768 684 2012 3642 6225 6948 5313 6936 876 38 3004 7440 4671 208 4906 4714 7067 3424 3163 6165 115 4974 2178 4613...

output:

701047464 

result:

ok 1 number(s): "701047464"

Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 15
Accepted

Test #9:

score: 15
Accepted
time: 1466ms
memory: 102156kb

input:

100000 50000 559705157 50000 50000
27437 48841 4744 41269 30017 24703 22660 38617 9707 42083 31500 14053 45335 20769 16455 30887 31847 6833 44822 14557 15400 18868 15093 47184 35490 48961 45686 45613 297 31598 7021 9194 30432 14570 44495 39114 21800 16034 12668 49738 20083 31717 22713 34958 46363 35...

output:

397469689 

result:

ok 1 number(s): "397469689"

Test #10:

score: 0
Accepted
time: 1367ms
memory: 104944kb

input:

100000 49999 86745154 49997 49997
48426 40553 19077 46485 43804 17022 31056 13627 31226 10367 13637 44826 33994 23159 9781 40172 19370 28896 31766 935 6943 7363 19203 27692 39512 28209 3294 33567 40851 19398 34866 35532 30821 43403 26783 26807 38940 48872 23076 40143 45338 36152 20857 38807 43963 49...

output:

785463309 

result:

ok 1 number(s): "785463309"

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 5
Accepted

Dependency #3:

100%
Accepted

Dependency #5:

100%
Accepted

Test #13:

score: 5
Accepted
time: 2374ms
memory: 101560kb

input:

100000 50000 116210524 739331537 739331537
28468 1684 43774 20012 16143 30422 26320 37470 18602 45764 9197 38675 11335 27052 37930 43558 38514 33720 36786 38149 12759 25898 29143 2671 47186 19877 19582 43378 16434 38070 37702 34232 24160 26875 14303 18186 6218 46623 41768 774 25988 12859 39939 9327 ...

output:

568504960 

result:

ok 1 number(s): "568504960"

Test #14:

score: 0
Accepted
time: 2579ms
memory: 103212kb

input:

100000 49999 838141856 974772137 974772137
12398 11958 19317 41187 48622 10113 28135 30927 4722 15323 37359 14284 4941 3540 46847 36704 6686 44955 29141 1546 945 42278 22876 48424 2519 46807 36818 19133 27934 45030 42377 36609 43243 2201 5986 36346 36683 5568 38112 33025 5690 2352 45838 42477 12959 ...

output:

573389237 

result:

ok 1 number(s): "573389237"

Subtask #8:

score: 0
Time Limit Exceeded

Dependency #7:

100%
Accepted

Test #15:

score: 0
Time Limit Exceeded

input:

100000 100000 187748990 613573870 613573870
98286 9398 93591 63433 65397 2084 94309 66738 9828 86362 42304 91596 20320 24261 99837 55266 2704 95755 44187 42056 5011 63865 47214 36791 11658 57641 48212 33208 99844 62177 43723 36732 65162 52978 60255 25999 32926 41172 22088 84345 96206 63169 47386 770...

output:


result:


Subtask #9:

score: 0
Skipped

Dependency #6:

0%

Subtask #10:

score: 0
Skipped

Dependency #4:

0%