QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#569958#9309. GraphLateRegistration#WA 1ms10024kbC++201.6kb2024-09-17 12:50:152024-09-17 12:50:19

Judging History

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

  • [2024-09-17 12:50:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:10024kb
  • [2024-09-17 12:50:15]
  • 提交

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)%mod;
		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]+mod-g0[k]+sp0[i-1])%mod;
		}
	}
	int ans=1;
	for(int l=1;l<=n;l++)
	{
		int r=n/(n/l);
		int sth=(findsl(n/l)+mod-findsl(n/(2*l)))%mod;
		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);
}

詳細信息

Test #1:

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

input:

4

output:

8

result:

ok answer is '8'

Test #2:

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

input:

2

output:

1

result:

ok answer is '1'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 9996kb

input:

123

output:

138256704

result:

wrong answer expected '671840470', found '138256704'