QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#138164 | #6740. Function | Nicolas125841 | ML | 42ms | 3756kb | C++17 | 1.1kb | 2023-08-11 02:27:28 | 2023-08-11 02:27:30 |
Judging History
answer
#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define depref(x, y) (x[y] - x[y-1])
unordered_map<ll, ll> s_f;
const ll mod = 998244353;
const ll CAP = 20210926;
const ll DPC = 100000;
vector<ll> dp(DPC + 1, 0);
void prep(){
dp[0] = 0;
dp[1] = 1;
for(int i = 2; i <= DPC; i++){
for(int j = 1; j * j <= i; j++){
if(i % j)
continue;
dp[i] += dp[i / j];
if(j * j != i)
dp[i] += dp[j];
dp[i] %= mod;
}
}
for(int i = 1; i <= DPC; i++)
dp[i] = (dp[i] + dp[i - 1]) % mod;
}
ll solve(ll n){
if(n <= DPC)
return dp[n];
if(s_f.find(n) != s_f.end())
return s_f[n];
ll ans = 0;
for(ll i = 1, ub; i <= n; i = ub + 1){
ub = n / (n / i);
ans += solve(n/i) * (min(CAP, ub) - i + 1) % mod;
ans %= mod;
}
return s_f[n] = ans;
}
int main(){
ll n;
cin >> n;
prep();
cout << solve(n) << "\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 42ms
memory: 3672kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 42ms
memory: 3756kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 42ms
memory: 3668kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 42ms
memory: 3652kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 42ms
memory: 3708kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 42ms
memory: 3700kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 42ms
memory: 3656kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: -100
Memory Limit Exceeded
input:
1000000