QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#128753 | #6740. Function | ckiseki# | AC ✓ | 370ms | 5776kb | C++20 | 1.5kb | 2023-07-21 15:33:11 | 2023-07-21 15:47:26 |
Judging History
answer
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
template <typename ...T>
void debug_(const char *s, T ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int cnt = sizeof...(T);
(..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename I>
void orange_(const char *s, I L, I R) {
cerr << "\e[1;32m[ " << s << " ] = [";
while (L != R) cerr << " " << *L++;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
const int mod = 998244353;
int add(int a, int b) {
return a + b >= mod ? a + b - mod : a + b;
}
int mul(int64_t a, int64_t b) {
return static_cast<int>(a * b % mod);
}
const int L = 2, R = 20210926;
int g(int n) {
static unordered_map<int,int> mp;
if (n <= 0)
return 0;
if (auto it = mp.find(n); it != mp.end()) {
return it->second;
}
int ans = 1;
for (int i = 1, j, s; i <= n; i = j) {
s = n / i;
j = n / s + 1;
// [i, j)
int l = max(L, i);
int r = min(R+1, j);
if (l < r) {
ans = add(ans, mul(r - l, g(s)));
}
}
return mp[n] = ans;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
cout << g(n) << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3456kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 9ms
memory: 3772kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 60ms
memory: 4076kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: 0
Accepted
time: 369ms
memory: 5776kb
input:
1000000000
output:
373787809
result:
ok 1 number(s): "373787809"
Test #12:
score: 0
Accepted
time: 369ms
memory: 5708kb
input:
999999999
output:
997616263
result:
ok 1 number(s): "997616263"
Test #13:
score: 0
Accepted
time: 365ms
memory: 5740kb
input:
999999990
output:
997615701
result:
ok 1 number(s): "997615701"
Test #14:
score: 0
Accepted
time: 370ms
memory: 5680kb
input:
999999900
output:
993928691
result:
ok 1 number(s): "993928691"
Test #15:
score: 0
Accepted
time: 351ms
memory: 5748kb
input:
999999000
output:
754532207
result:
ok 1 number(s): "754532207"
Test #16:
score: 0
Accepted
time: 366ms
memory: 5720kb
input:
999990000
output:
996592686
result:
ok 1 number(s): "996592686"
Test #17:
score: 0
Accepted
time: 362ms
memory: 5744kb
input:
999900000
output:
311678722
result:
ok 1 number(s): "311678722"
Test #18:
score: 0
Accepted
time: 367ms
memory: 5732kb
input:
999000000
output:
60462624
result:
ok 1 number(s): "60462624"
Test #19:
score: 0
Accepted
time: 367ms
memory: 5708kb
input:
990000000
output:
444576800
result:
ok 1 number(s): "444576800"
Test #20:
score: 0
Accepted
time: 335ms
memory: 5704kb
input:
900000000
output:
95615129
result:
ok 1 number(s): "95615129"
Test #21:
score: 0
Accepted
time: 4ms
memory: 3560kb
input:
1361956
output:
813433539
result:
ok 1 number(s): "813433539"
Test #22:
score: 0
Accepted
time: 10ms
memory: 3748kb
input:
7579013
output:
677659797
result:
ok 1 number(s): "677659797"
Test #23:
score: 0
Accepted
time: 11ms
memory: 3684kb
input:
8145517
output:
801509527
result:
ok 1 number(s): "801509527"
Test #24:
score: 0
Accepted
time: 10ms
memory: 3692kb
input:
6140463
output:
869023935
result:
ok 1 number(s): "869023935"
Test #25:
score: 0
Accepted
time: 6ms
memory: 3672kb
input:
3515281
output:
989091505
result:
ok 1 number(s): "989091505"
Test #26:
score: 0
Accepted
time: 9ms
memory: 3760kb
input:
6969586
output:
539840131
result:
ok 1 number(s): "539840131"