QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#572518 | #9309. Graph | OIer_kzc | WA | 102ms | 106232kb | C++14 | 1.5kb | 2024-09-18 15:06:20 | 2024-09-18 15:06:20 |
Judging History
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 = 20000005;
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[N], 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() {
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: 87ms
memory: 104192kb
input:
4
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 97ms
memory: 106168kb
input:
2
output:
1
result:
ok answer is '1'
Test #3:
score: 0
Accepted
time: 91ms
memory: 106232kb
input:
123
output:
671840470
result:
ok answer is '671840470'
Test #4:
score: 0
Accepted
time: 93ms
memory: 105416kb
input:
233
output:
353738465
result:
ok answer is '353738465'
Test #5:
score: 0
Accepted
time: 93ms
memory: 105816kb
input:
5981
output:
970246821
result:
ok answer is '970246821'
Test #6:
score: 0
Accepted
time: 91ms
memory: 106112kb
input:
86422
output:
897815688
result:
ok answer is '897815688'
Test #7:
score: 0
Accepted
time: 97ms
memory: 105408kb
input:
145444
output:
189843901
result:
ok answer is '189843901'
Test #8:
score: 0
Accepted
time: 89ms
memory: 105560kb
input:
901000
output:
819449452
result:
ok answer is '819449452'
Test #9:
score: 0
Accepted
time: 102ms
memory: 105032kb
input:
1000000
output:
113573943
result:
ok answer is '113573943'
Test #10:
score: -100
Wrong Answer
time: 93ms
memory: 104684kb
input:
23333333
output:
133173007
result:
wrong answer expected '949849384', found '133173007'