QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#576541#9309. GraphUESTC_DECAYALIWA 37ms13716kbC++201.4kb2024-09-19 20:54:512024-09-19 20:54:51

Judging History

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

  • [2024-09-19 20:54:51]
  • 评测
  • 测评结果:WA
  • 用时:37ms
  • 内存:13716kb
  • [2024-09-19 20:54:51]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<cmath>
#define int long long
#define RI register int
#define CI const int&
using namespace std;
const int mod=998244353;
namespace Min25_Sieve
{
	const int N=1e6+5;
	int n,lim,pri[N],cnt,vis[N],id1[N],id2[N],g[N],w[N],idx;
	inline int ID(CI x)
	{
		return x<=lim?id1[x]:id2[n/x];
	}
	inline void init(CI nn)
	{
		n=nn; lim=(int)sqrt(n); 
		for (RI i=2;i<=lim;++i)
		{
			if (!vis[i]) pri[++cnt]=i;
			for (RI j=1;j<=cnt&&i*pri[j]<=lim;++j)
			if (vis[i*pri[j]]=1,i%pri[j]==0) break;
		}
		for (RI l=1,r;l<=n;l=r+1)
		{
			r=n/(n/l); w[++idx]=n/l;
			if (n/l<=lim) id1[n/l]=idx;
			else id2[n/(n/l)]=idx;
			g[idx]=w[idx]-1;
		}
		for (RI j=1;j<=cnt;++j)
		for (RI i=1;i<=idx;++i)
		{
			if (pri[j]*pri[j]>w[i]) break;
			g[i]-=g[ID(w[i]/pri[j])]-(j-1);
		}
	}
	inline int work(CI n)
	{
		return n<=1?0:g[ID(n)];
	}
};
using namespace Min25_Sieve;
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
	for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
inline int solve(CI m)
{
	if (m<=2) return 1;
	if (m==3) return 3;
	int tot=work(m)-work(m/2);
	return quick_pow(m,tot)*(m-(tot+1)%mod+mod)%mod;
}
signed main()
{
	int n; scanf("%lld",&n);
	init(n); int ans=1;
	for (RI l=1,r;l<=n;l=r+1)
	r=n/(n/l),(ans*=quick_pow(solve(n/l),r-l+1))%=mod;
	return printf("%lld",ans),0;
}

詳細信息

Test #1:

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

input:

4

output:

8

result:

ok answer is '8'

Test #2:

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

input:

2

output:

1

result:

ok answer is '1'

Test #3:

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

input:

123

output:

671840470

result:

ok answer is '671840470'

Test #4:

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

input:

233

output:

353738465

result:

ok answer is '353738465'

Test #5:

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

input:

5981

output:

970246821

result:

ok answer is '970246821'

Test #6:

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

input:

86422

output:

897815688

result:

ok answer is '897815688'

Test #7:

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

input:

145444

output:

189843901

result:

ok answer is '189843901'

Test #8:

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

input:

901000

output:

819449452

result:

ok answer is '819449452'

Test #9:

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

input:

1000000

output:

113573943

result:

ok answer is '113573943'

Test #10:

score: 0
Accepted
time: 3ms
memory: 10144kb

input:

23333333

output:

949849384

result:

ok answer is '949849384'

Test #11:

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

input:

102850434

output:

604886751

result:

ok answer is '604886751'

Test #12:

score: 0
Accepted
time: 11ms
memory: 12748kb

input:

998244353

output:

0

result:

ok answer is '0'

Test #13:

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

input:

1000000007

output:

318420284

result:

ok answer is '318420284'

Test #14:

score: 0
Accepted
time: 24ms
memory: 13104kb

input:

2147483547

output:

688759898

result:

ok answer is '688759898'

Test #15:

score: -100
Wrong Answer
time: 37ms
memory: 13716kb

input:

5120103302

output:

406301251

result:

wrong answer expected '116870489', found '406301251'