QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#577933#9309. GraphdoctorZ_WA 0ms6056kbC++141.3kb2024-09-20 15:32:042024-09-20 15:32:05

Judging History

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

  • [2024-09-20 15:32:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:6056kb
  • [2024-09-20 15:32:04]
  • 提交

answer

#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
const ll mod=99824353;
ll ksm(ll a,ll b)
{
	if(b==0) return 1;
	ll tmp=ksm(a,b>>1);
	if(b&1) return tmp*tmp%mod*a%mod;
	else return tmp*tmp%mod; 
}
const int N=1e6+1000;
ll n,sqn,w[N+10];
int cnt,prime[N+10];
bool vis[N+10];
void init()
{
	for(int i=2;i<=sqn;i++)
	{
		if(!vis[i])
			prime[++prime[0]]=i;
		for(int j=1;j<=prime[0]&&i*prime[j]<=sqn;j++)
		{
			vis[i*prime[j]]=0;
			if(i%prime[j]==0) break;
		}
	}
}
int id1[N+10],id2[N+10];
int id(ll x)
{
	if(x<=sqn) return id1[x];
	else return id2[n/x];
}
ll g[N+10];
ll f(ll m)
{
	if(m==1) return 1;
	ll k=g[id(m)]-g[id(m/2)]+1;
	if(k==m) return ksm(m,k-2);
	else return ksm(m,k-1)*(m-k)%mod;
}
int main()
{
//	freopen("B.in","r",stdin);
	scanf("%lld",&n);
	sqn=sqrt(n);
//	printf("%lld\n",sqn);
	for(ll l=1,r;l<=n;l=r+1)
	{
		r=n/(n/l);
		w[++cnt]=n/l;
		if(w[cnt]>sqn) id2[n/w[cnt]]=cnt;
		else id1[w[cnt]]=cnt;
	}
	init();
	for(int i=1;i<=cnt;i++) g[i]=w[i]-1;
	for(int i=1;i<=prime[0];i++)
		for(int j=1;j<=cnt&&1ll*prime[i]*prime[i]<=w[j];j++)
			g[j]=g[j]-(g[id(w[j]/prime[i])]-(i-1));
	ll ans=1;
	for(ll l=1,r;l<=n;l=r+1)
	{
		r=n/(n/l);
//		printf("%lld %lld\n",n/l,f(n/l));
		ans=ans*ksm(f(n/l),r-l+1)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 6052kb

input:

4

output:

8

result:

ok answer is '8'

Test #2:

score: 0
Accepted
time: 0ms
memory: 6040kb

input:

2

output:

1

result:

ok answer is '1'

Test #3:

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

input:

123

output:

44314117

result:

wrong answer expected '671840470', found '44314117'