QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#574467 | #9309. Graph | Andyqian7 | AC ✓ | 320ms | 17584kb | C++14 | 1.3kb | 2024-09-18 22:15:22 | 2024-09-18 22:15:23 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
int len, lim, lenp, a[7000000], g[7000000];
const int MOD = 998244353;
int n;
int fp(int x, int k)
{
if (!k)
return 1;
if (k & 1)
return x * fp(x, k - 1) % MOD;
int tmp = fp(x, k >> 1);
return tmp * tmp % MOD;
}
inline int get_index(int x)
{
if (x <= lim)
return x;
else
return len - n / x + 1;
}
int cnt(int n)
{
lim = sqrt(n);
for (int i = 1; i <= n; i = a[len] + 1)
{
a[++len] = n / (n / i);
g[len] = a[len] - 1;
}
for (int i = 2; i <= lim; ++i)
{
if (g[i] != g[i - 1])
{
++lenp;
for (int j = len; a[j] >= 1ll * i * i; --j)
g[j] = g[j] - g[get_index(a[j] / i)] + lenp - 1;
}
}
return g[len];
}
int f(int n)
{
return g[get_index(n)] - g[get_index(n / 2)];
}
int F(int n)
{
if (n <= 2)
return 1;
if (n == 3)
return 3;
int tmp = f(n);
return fp(n % MOD, tmp) * (n % MOD - tmp % MOD - 1 + MOD) % MOD;
}
signed main()
{
cin >> n;
int ans = 1;
cnt(n);
for (int l = 1, r; l <= n; l = r + 1)
{
r = n / (n / l);
ans = ans * fp(F(n / l), r - l + 1) % MOD;
}
cout << ans;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5760kb
input:
4
output:
8
result:
ok answer is '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5784kb
input:
2
output:
1
result:
ok answer is '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5704kb
input:
123
output:
671840470
result:
ok answer is '671840470'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5668kb
input:
233
output:
353738465
result:
ok answer is '353738465'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5580kb
input:
5981
output:
970246821
result:
ok answer is '970246821'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5572kb
input:
86422
output:
897815688
result:
ok answer is '897815688'
Test #7:
score: 0
Accepted
time: 1ms
memory: 5720kb
input:
145444
output:
189843901
result:
ok answer is '189843901'
Test #8:
score: 0
Accepted
time: 1ms
memory: 5784kb
input:
901000
output:
819449452
result:
ok answer is '819449452'
Test #9:
score: 0
Accepted
time: 2ms
memory: 7772kb
input:
1000000
output:
113573943
result:
ok answer is '113573943'
Test #10:
score: 0
Accepted
time: 3ms
memory: 5780kb
input:
23333333
output:
949849384
result:
ok answer is '949849384'
Test #11:
score: 0
Accepted
time: 0ms
memory: 5884kb
input:
102850434
output:
604886751
result:
ok answer is '604886751'
Test #12:
score: 0
Accepted
time: 17ms
memory: 8300kb
input:
998244353
output:
0
result:
ok answer is '0'
Test #13:
score: 0
Accepted
time: 17ms
memory: 8000kb
input:
1000000007
output:
318420284
result:
ok answer is '318420284'
Test #14:
score: 0
Accepted
time: 26ms
memory: 8228kb
input:
2147483547
output:
688759898
result:
ok answer is '688759898'
Test #15:
score: 0
Accepted
time: 45ms
memory: 6896kb
input:
5120103302
output:
116870489
result:
ok answer is '116870489'
Test #16:
score: 0
Accepted
time: 109ms
memory: 11536kb
input:
19834593299
output:
523663743
result:
ok answer is '523663743'
Test #17:
score: 0
Accepted
time: 207ms
memory: 14232kb
input:
52500109238
output:
195086665
result:
ok answer is '195086665'
Test #18:
score: 0
Accepted
time: 280ms
memory: 17584kb
input:
84848352911
output:
107959260
result:
ok answer is '107959260'
Test #19:
score: 0
Accepted
time: 320ms
memory: 17516kb
input:
99824435322
output:
0
result:
ok answer is '0'
Test #20:
score: 0
Accepted
time: 319ms
memory: 14988kb
input:
99999999354
output:
316301711
result:
ok answer is '316301711'
Test #21:
score: 0
Accepted
time: 320ms
memory: 16696kb
input:
100000000000
output:
396843576
result:
ok answer is '396843576'
Extra Test:
score: 0
Extra Test Passed