QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#347508 | #6740. Function | wtz2333 | TL | 362ms | 4576kb | C++17 | 1.2kb | 2024-03-09 14:04:15 | 2024-03-09 14:04:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mo = 998244353;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
map<int,int> mp;
auto calc = [&](auto self,int x) -> int {
if(x == 0)return 0;
if(mp.find(x) != mp.end()) return mp[x];
int l = 2,r;
ll ans = 1;
while(l <= 20210926){
ll t = x / l;
if(t) r = min(x / (x / l),20210926);
else r = 20210926;
ans += 1ll * (r - l + 1) * self(self,x / l) % mo;
ans %= mo;
l = r + 1;
}
return mp[x] = ans;
};
if(n > 1) {
cout << calc(calc,n) << endl;
}else {
ll ans = 0;
int cnt = 1;
vector<int> f(n + 1,1);
for(int i = n - 1;i >= 1;i --) {
for(int j = 2 * i;j <= n;j += i) {
f[i] += f[j];
// cerr << f[j] << " ";
}//cerr << endl;
}
cout << f[1] << endl;
}
}
// n / 20210926 <= k
/// 1 2 3 4 5 6 7 8
// 14 5 2 2 1 1 1 1
// 13 4 1 1 0 0 0 0
// 12 3 0 0 0 0 0 0
//
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 5ms
memory: 3668kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 55ms
memory: 4168kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 362ms
memory: 4576kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: -100
Time Limit Exceeded
input:
1000000000