QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#621129 | #9309. Graph | Galex | AC ✓ | 291ms | 28848kb | C++14 | 1.5kb | 2024-10-08 09:34:07 | 2024-10-08 09:34:08 |
Judging History
answer
#include <bits/stdc++.h>
#define LL long long
#define int LL
using namespace std;
LL read() {
LL s = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
f = (ch == '-' ? -1 : 1), ch = getchar();
while (ch >= '0' && ch <= '9')
s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
return s * f;
}
const int MAXN = 1e6 + 5, mod = 998244353;
int qpow(int a, LL b) {
int res = 1;
while (b) {
if (b & 1)
res = 1ll * res * a % mod;
a = 1ll * a * a % mod, b >>= 1;
}
return res;
}
LL n, N;
bool vis[MAXN];
int pr[MAXN], tot = 0;
int m;
LL g1[MAXN], v[MAXN];
int id1[MAXN], id2[MAXN];
void szs() {
for (int i = 2; i <= N; i++) {
if (!vis[i])
pr[++tot] = i;
for (int j = 1; i * pr[j] <= N; j++) {
vis[i * pr[j]] = true;
if (i % pr[j] == 0)
break;
}
}
}
int id(LL x) {
return x <= N ? id1[x] : id2[n / x];
}
int calc(LL m) {
if (m <= 2) return 1;
if (m == 3) return 3;
LL c = g1[id(m)] - g1[id(m / 2)];
return 1ll * qpow(m % mod, c) * ((m - c - 1 + mod) % mod) % mod;
}
signed main() {
n = read(), N = sqrt(n);
szs();
for (LL l = 1, r; l <= n; l = r + 1) {
r = n / (n / l), v[++m] = n / l;
g1[m] = n / l - 1;
v[m] <= N ? id1[v[m]] = m : id2[n / v[m]] = m;
}
for (int i = 1; i <= tot; i++)
for (int j = 1; pr[i] * pr[i] <= v[j]; j++)
g1[j] -= g1[id(v[j] / pr[i])] - (i - 1);
int ans = 1;
for (LL l = 1, r; l <= n; l = r + 1)
r = n / (n / l), ans = 1ll * ans * qpow(calc(n / l), r - l + 1) % mod;
printf("%d", ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 9848kb
input:
4
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 1ms
memory: 10052kb
input:
2
output:
1
result:
ok answer is '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 9976kb
input:
123
output:
671840470
result:
ok answer is '671840470'
Test #4:
score: 0
Accepted
time: 1ms
memory: 9976kb
input:
233
output:
353738465
result:
ok answer is '353738465'
Test #5:
score: 0
Accepted
time: 1ms
memory: 10004kb
input:
5981
output:
970246821
result:
ok answer is '970246821'
Test #6:
score: 0
Accepted
time: 1ms
memory: 10056kb
input:
86422
output:
897815688
result:
ok answer is '897815688'
Test #7:
score: 0
Accepted
time: 1ms
memory: 9980kb
input:
145444
output:
189843901
result:
ok answer is '189843901'
Test #8:
score: 0
Accepted
time: 1ms
memory: 9920kb
input:
901000
output:
819449452
result:
ok answer is '819449452'
Test #9:
score: 0
Accepted
time: 1ms
memory: 9904kb
input:
1000000
output:
113573943
result:
ok answer is '113573943'
Test #10:
score: 0
Accepted
time: 2ms
memory: 9940kb
input:
23333333
output:
949849384
result:
ok answer is '949849384'
Test #11:
score: 0
Accepted
time: 2ms
memory: 9952kb
input:
102850434
output:
604886751
result:
ok answer is '604886751'
Test #12:
score: 0
Accepted
time: 15ms
memory: 12320kb
input:
998244353
output:
0
result:
ok answer is '0'
Test #13:
score: 0
Accepted
time: 11ms
memory: 12452kb
input:
1000000007
output:
318420284
result:
ok answer is '318420284'
Test #14:
score: 0
Accepted
time: 23ms
memory: 10496kb
input:
2147483547
output:
688759898
result:
ok answer is '688759898'
Test #15:
score: 0
Accepted
time: 41ms
memory: 12716kb
input:
5120103302
output:
116870489
result:
ok answer is '116870489'
Test #16:
score: 0
Accepted
time: 94ms
memory: 19376kb
input:
19834593299
output:
523663743
result:
ok answer is '523663743'
Test #17:
score: 0
Accepted
time: 188ms
memory: 21628kb
input:
52500109238
output:
195086665
result:
ok answer is '195086665'
Test #18:
score: 0
Accepted
time: 261ms
memory: 26132kb
input:
84848352911
output:
107959260
result:
ok answer is '107959260'
Test #19:
score: 0
Accepted
time: 283ms
memory: 26148kb
input:
99824435322
output:
0
result:
ok answer is '0'
Test #20:
score: 0
Accepted
time: 291ms
memory: 26160kb
input:
99999999354
output:
316301711
result:
ok answer is '316301711'
Test #21:
score: 0
Accepted
time: 279ms
memory: 28848kb
input:
100000000000
output:
396843576
result:
ok answer is '396843576'
Extra Test:
score: 0
Extra Test Passed