QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569986#9309. GraphLateRegistration#AC ✓290ms27204kbC++201.5kb2024-09-17 13:05:352024-09-17 13:05:35

Judging History

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

  • [2024-09-17 13:05:35]
  • 评测
  • 测评结果:AC
  • 用时:290ms
  • 内存:27204kb
  • [2024-09-17 13:05:35]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define mod 998244353
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
bool vis[1000005];
int pri[1000005],cnt;
int sp0[1000005];
int g0[1000005];
int id1[1000005],id2[1000005],tot;
int w[1000005];
void findpri(int n)
{
	vis[1]=true;
	for(int i=2;i<=n;i++)
	{
		if(!vis[i])
		{
			pri[++cnt]=i;
			sp0[cnt]=(sp0[cnt-1]+1);
		}
		for(int j=1;j<=cnt&&i*pri[j]<=n;j++)
		{
			vis[i*pri[j]]=true;
			if(i%pri[j]==0)break;
		}
	}
}
int n,sn;
int findsl(int x)
{
	int k=x<=sn?id1[x]:id2[n/x];
	return g0[k];
}
int ksm(int n,int k)
{
	int ans=1;
	while(k>=1)
	{
		if(k&1)ans=1LL*ans*n%mod;
		k>>=1;
		n=1LL*n*n%mod;
	}
	return ans;
}
signed main()
{
	int xx;
	n=read();
	sn=sqrt((double)n);
	findpri(sn);
	for(int l=1,r;l<=n;l=r+1)
	{
		r=n/(n/l);
		w[++tot]=n/l;
		xx=(w[tot]-1);
		g0[tot]=xx;
		if(n/l<=sn)id1[n/l]=tot;
		else id2[n/(n/l)]=tot;
	}
	for(int i=1;i<=cnt;i++)
	{
		for(int j=1;j<=tot&&pri[i]*pri[i]<=w[j];j++)
		{
			int k=w[j]/pri[i]<=sn?id1[w[j]/pri[i]]:id2[n/(w[j]/pri[i])];
			g0[j]=(g0[j]-g0[k]+sp0[i-1]);
		}
	}
	int ans=1;
	for(int l=1,r;l<=n;l=r+1)
	{
		r=n/(n/l);
		int sth=(findsl(n/l)-findsl(n/(2*l)));
		int sy=((n/l)-1-sth)%mod;
		if(sy==0)sy=1,sth--;
		int now=1LL*ksm((n/l)%mod,sth)*sy%mod;
		ans=1LL*ans*ksm(now,r-l+1)%mod;
	}
	printf("%lld\n",ans);
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7812kb

input:

4

output:

8

result:

ok answer is '8'

Test #2:

score: 0
Accepted
time: 1ms
memory: 9920kb

input:

2

output:

1

result:

ok answer is '1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 10072kb

input:

123

output:

671840470

result:

ok answer is '671840470'

Test #4:

score: 0
Accepted
time: 1ms
memory: 7888kb

input:

233

output:

353738465

result:

ok answer is '353738465'

Test #5:

score: 0
Accepted
time: 1ms
memory: 7932kb

input:

5981

output:

970246821

result:

ok answer is '970246821'

Test #6:

score: 0
Accepted
time: 1ms
memory: 7968kb

input:

86422

output:

897815688

result:

ok answer is '897815688'

Test #7:

score: 0
Accepted
time: 1ms
memory: 7952kb

input:

145444

output:

189843901

result:

ok answer is '189843901'

Test #8:

score: 0
Accepted
time: 1ms
memory: 10040kb

input:

901000

output:

819449452

result:

ok answer is '819449452'

Test #9:

score: 0
Accepted
time: 1ms
memory: 7912kb

input:

1000000

output:

113573943

result:

ok answer is '113573943'

Test #10:

score: 0
Accepted
time: 2ms
memory: 10192kb

input:

23333333

output:

949849384

result:

ok answer is '949849384'

Test #11:

score: 0
Accepted
time: 2ms
memory: 8244kb

input:

102850434

output:

604886751

result:

ok answer is '604886751'

Test #12:

score: 0
Accepted
time: 15ms
memory: 10800kb

input:

998244353

output:

0

result:

ok answer is '0'

Test #13:

score: 0
Accepted
time: 14ms
memory: 10808kb

input:

1000000007

output:

318420284

result:

ok answer is '318420284'

Test #14:

score: 0
Accepted
time: 23ms
memory: 13236kb

input:

2147483547

output:

688759898

result:

ok answer is '688759898'

Test #15:

score: 0
Accepted
time: 37ms
memory: 13424kb

input:

5120103302

output:

116870489

result:

ok answer is '116870489'

Test #16:

score: 0
Accepted
time: 98ms
memory: 17224kb

input:

19834593299

output:

523663743

result:

ok answer is '523663743'

Test #17:

score: 0
Accepted
time: 184ms
memory: 23844kb

input:

52500109238

output:

195086665

result:

ok answer is '195086665'

Test #18:

score: 0
Accepted
time: 256ms
memory: 25272kb

input:

84848352911

output:

107959260

result:

ok answer is '107959260'

Test #19:

score: 0
Accepted
time: 290ms
memory: 27088kb

input:

99824435322

output:

0

result:

ok answer is '0'

Test #20:

score: 0
Accepted
time: 290ms
memory: 25300kb

input:

99999999354

output:

316301711

result:

ok answer is '316301711'

Test #21:

score: 0
Accepted
time: 280ms
memory: 27204kb

input:

100000000000

output:

396843576

result:

ok answer is '396843576'

Extra Test:

score: 0
Extra Test Passed