QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#132920 | #6740. Function | Nicolas125841 | TL | 969ms | 789804kb | C++17 | 1.4kb | 2023-08-01 06:29:28 | 2023-08-01 06:29:31 |
Judging History
answer
#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// To use most b i ts rather than jus t the lowest ones :
struct chash { // large odd number for C
const uint64_t C = ll(4e18 * acos(0)) | 71;
ll operator()(ll x) const { return __builtin_bswap64(x*C); }
};
__gnu_pbds::gp_hash_table<ll,ll,chash> rdp({},{},{},{},{1<<25});
const ll mod = 998244353;
const ll N = 20210926;
const ll DPC = 31627;
ll TN;
vector<ll> dp(DPC, 0);
void prep(){
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 rec(ll n){
if(TN / n < DPC)
return dp[TN / n];
if(rdp.find(n) != rdp.end())
return rdp[n];
ll ans = 1;
for(ll v = 2; v < DPC; v++){
if(v * n <= TN)
ans += rec(v * n);
ll ub = min(N, TN / (n * (v - 1)));
ll lb = max(DPC, TN / (n * v) + 1);
if(ub >= lb)
ans += (ub - lb + 1) * dp[v - 1];
ans %= mod;
}
rdp[n] = ans;
return ans;
}
int main(){
cin >> TN;
prep();
cout << rec(1) << "\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 108ms
memory: 789720kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 96ms
memory: 789724kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 107ms
memory: 789720kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 89ms
memory: 789708kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 99ms
memory: 789804kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 111ms
memory: 789792kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 107ms
memory: 789720kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 98ms
memory: 789684kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 180ms
memory: 789672kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 969ms
memory: 789716kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: -100
Time Limit Exceeded
input:
1000000000