QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578817#9309. GraphSSL_TJHWA 3ms7060kbC++141.5kb2024-09-20 21:35:212024-09-20 21:35:22

Judging History

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

  • [2024-09-20 21:35:22]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:7060kb
  • [2024-09-20 21:35:21]
  • 提交

answer

#include<bits/stdc++.h>
#define MOD 998244353
using namespace std;

typedef long long ll;

const ll MAXN=1e11;
const int N=1e5;
// SQRN is exactly floor(sqrt(n)), PNUM is the number of primes not greater than SQRN

ll POW(ll x, ll y) {
	ll re = 1;
	while (y) {
		if (y & 1) re = re * x % MOD;
		x = x * x % MOD; y >>= 1;
	}
	return re;
}

int p1,vt,z[N+5],pr[N+5];
long long n,x,v[N+5],f[2][N+5],s[N+5],g[N+5];
void dd(){
	for(int i=2;i<=N;i++){
		if(!z[i]){
			pr[++p1]=i;
			s[p1]=p1;
		}
		for(int j=1;j<=p1&&i*pr[j]<=N;j++){
			z[i*pr[j]]=1;
			if(i%pr[j]==0) break;
		}
	}
}
void init(){
	x=sqrt(n)+1;
	dd();
	for(long long l=1,r;l<=n;l=r+1){
		r=n/(n/l);
		v[++vt]=n/l;
		if(n/l<=x) f[0][n/l]=vt;
		else f[1][l]=vt;
		long long t=n/l;
		g[vt]=t-1;
	}
	long long w;
	for(int i=1;i<=p1;i++){
		w=1ll*pr[i]*pr[i];
		long long t;
		for(int j=1;j<=vt&&w<=v[j];j++){
			t=v[j]/pr[i];
			if(t<=x) t=f[0][t];
			else t=f[1][n/t];
			g[j]-=g[t]-s[i-1];
		}
	}
	
}
long long S(long long p,int q){
	if(pr[q]>=p) return 0;
	long long td=(p<=x?f[0][p]:f[1][n/p]);
	long long re=g[td]-s[q];
	return re;
}

int quest(ll m) {
	n = m;
	init();
	return S(n,0);
}

int main() {
	ll nn;
	scanf("%lld", &nn);
	
	int re = 0;
	for (ll L = 1, R; L <= nn; L = R + 1) {
		R = nn / (nn / L);
		int k = (nn / L) % MOD;
		int awa = (quest(k) - quest(k / 2) + MOD - 1) % (MOD - 1);
		(re += (R - L + 1) % MOD * POW(k, awa) % MOD) %= MOD;
	}
	printf("%lld", re);
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 7060kb

input:

4

output:

8

result:

ok answer is '8'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 6576kb

input:

2

output:

3

result:

wrong answer expected '1', found '3'