QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572526#9309. GraphOIer_kzcRE 949ms1023428kbC++141.6kb2024-09-18 15:09:502024-09-18 15:09:50

Judging History

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

  • [2024-09-18 15:09:50]
  • 评测
  • 测评结果:RE
  • 用时:949ms
  • 内存:1023428kb
  • [2024-09-18 15:09:50]
  • 提交

answer

#include <stdio.h>
#include <string.h>

#include <bitset>
#include <vector>
#include <algorithm>

#define LOG(FMT...) fprintf(stderr, FMT)

#define eb emplace_back

using namespace std;

typedef long long LL;
constexpr int N = 200000005, PC = 11078937;
constexpr int mod = 998244353;

char gc() {
	static char buf[1 << 21], *p1 = buf, *p2 = buf;
	return (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? -1 : *p1++);
}
int read() {
	int x = 0; char c = gc();
	while (c < 48 || c > 57) {
		c = gc();
	}
	for (; c > 47 && c < 58; c = gc()) {
		x = x * 10 + (c ^ 48);
	}
	return x;
}

int pr[PC], cnt;
bool was[N];
int c[N];

void sieve() {
	for (int x = 2; x < N; ++x) {
		if (!was[x]) {
			pr[cnt++] = x;
		}
		for (int k = 0; x * pr[k] < N; ++k) {
			was[x * pr[k]] = true;
			if (!(x % pr[k])) {
				break;
			}
		}
	}
	for (int i = 2; i < N; ++i) {
		c[i] = c[i - 1] + !was[i];
	}
}

constexpr int inv(int x, int k = mod - 2) {
	int r = 1;
	while (k) {
		if (k & 1) {
			r = x * (LL)r % mod;
		}
		x = x * (LL)x % mod;
		k >>= 1;
	}
	return r;
}

constexpr int f(int x) {
	if (x == 1) {
		return 1;
	}
	if (x == 2) {
		return 1;
	}
	if (x == 3) {
		return 3;
	}
	int y = c[x] - c[x / 2];
	return (x - y - 1) * (LL)inv(x, y) % mod;
}

int main() {
	// LOG("%.3lf\n", (sizeof c + sizeof was + sizeof pr) / 1048576.0);
	sieve();
	LL n;
	scanf("%lld", &n);
	int res = 1;
	for (LL l = 1, r; l <= n; l = r + 1) {
		r = n / (n / l);
		res = res * (LL)inv(f(n / r), r - l + 1) % mod;
	}
	printf("%d\n", res);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 949ms
memory: 1022120kb

input:

4

output:

8

result:

ok answer is '8'

Test #2:

score: 0
Accepted
time: 926ms
memory: 1022984kb

input:

2

output:

1

result:

ok answer is '1'

Test #3:

score: 0
Accepted
time: 902ms
memory: 1023428kb

input:

123

output:

671840470

result:

ok answer is '671840470'

Test #4:

score: 0
Accepted
time: 948ms
memory: 1022892kb

input:

233

output:

353738465

result:

ok answer is '353738465'

Test #5:

score: 0
Accepted
time: 903ms
memory: 1022432kb

input:

5981

output:

970246821

result:

ok answer is '970246821'

Test #6:

score: 0
Accepted
time: 925ms
memory: 1021764kb

input:

86422

output:

897815688

result:

ok answer is '897815688'

Test #7:

score: 0
Accepted
time: 942ms
memory: 1022772kb

input:

145444

output:

189843901

result:

ok answer is '189843901'

Test #8:

score: 0
Accepted
time: 934ms
memory: 1022144kb

input:

901000

output:

819449452

result:

ok answer is '819449452'

Test #9:

score: 0
Accepted
time: 934ms
memory: 1021624kb

input:

1000000

output:

113573943

result:

ok answer is '113573943'

Test #10:

score: 0
Accepted
time: 920ms
memory: 1022248kb

input:

23333333

output:

949849384

result:

ok answer is '949849384'

Test #11:

score: 0
Accepted
time: 888ms
memory: 1023336kb

input:

102850434

output:

604886751

result:

ok answer is '604886751'

Test #12:

score: -100
Runtime Error

input:

998244353

output:


result: