QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#132948 | #6740. Function | Nicolas125841 | AC ✓ | 427ms | 789780kb | C++17 | 1.9kb | 2023-08-01 10:48:58 | 2023-08-01 10:48:59 |
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])
// 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);
ll solve(){
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 ans = dp[min(TN, DPC - 1)];
ll tans = 0;
for(ll i = 1; i < DPC; i++){
tans = 0;
for(ll v = (DPC + i - 1) / i; v * i <= TN && v < DPC;){
ll dpi = TN / (i * v);
ll ub = min(DPC, (TN / dpi) / i + 1);
//cout << dpi << " " << TN / (i * (ub - 1)) << " " << v << " " << ub << "\n";
//assert(dpi == TN / (i * (ub - 1)) && dpi != TN / (i * ub));
tans += (ub - v) * dp[dpi] % mod;
v = ub;
}
tans = tans * depref(dp, i) % mod;
ans = (ans + tans) % mod;
for(ll v = 2; v < DPC; v++){
if(TN / (i * (v - 1)) < DPC)
break;
ll ub = min(N, TN / (i * (v - 1)));
ll lb = max(DPC, TN / (i * v) + 1);
if(ub >= lb)
ans += (depref(dp, i) * ((ub - lb + 1) * dp[v - 1]) % mod) % mod;
ans %= mod;
}
}
return ans;
}
int main(){
cin >> TN;
cout << solve() << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 103ms
memory: 789728kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 115ms
memory: 789696kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 98ms
memory: 789764kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 99ms
memory: 789716kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 94ms
memory: 789744kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 92ms
memory: 789692kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 103ms
memory: 789764kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 127ms
memory: 789660kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 124ms
memory: 789720kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 184ms
memory: 789700kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: 0
Accepted
time: 394ms
memory: 789736kb
input:
1000000000
output:
373787809
result:
ok 1 number(s): "373787809"
Test #12:
score: 0
Accepted
time: 395ms
memory: 789708kb
input:
999999999
output:
997616263
result:
ok 1 number(s): "997616263"
Test #13:
score: 0
Accepted
time: 403ms
memory: 789720kb
input:
999999990
output:
997615701
result:
ok 1 number(s): "997615701"
Test #14:
score: 0
Accepted
time: 427ms
memory: 789736kb
input:
999999900
output:
993928691
result:
ok 1 number(s): "993928691"
Test #15:
score: 0
Accepted
time: 410ms
memory: 789704kb
input:
999999000
output:
754532207
result:
ok 1 number(s): "754532207"
Test #16:
score: 0
Accepted
time: 394ms
memory: 789700kb
input:
999990000
output:
996592686
result:
ok 1 number(s): "996592686"
Test #17:
score: 0
Accepted
time: 418ms
memory: 789716kb
input:
999900000
output:
311678722
result:
ok 1 number(s): "311678722"
Test #18:
score: 0
Accepted
time: 402ms
memory: 789780kb
input:
999000000
output:
60462624
result:
ok 1 number(s): "60462624"
Test #19:
score: 0
Accepted
time: 391ms
memory: 789776kb
input:
990000000
output:
444576800
result:
ok 1 number(s): "444576800"
Test #20:
score: 0
Accepted
time: 408ms
memory: 789740kb
input:
900000000
output:
95615129
result:
ok 1 number(s): "95615129"
Test #21:
score: 0
Accepted
time: 114ms
memory: 789716kb
input:
1361956
output:
813433539
result:
ok 1 number(s): "813433539"
Test #22:
score: 0
Accepted
time: 132ms
memory: 789724kb
input:
7579013
output:
677659797
result:
ok 1 number(s): "677659797"
Test #23:
score: 0
Accepted
time: 114ms
memory: 789688kb
input:
8145517
output:
801509527
result:
ok 1 number(s): "801509527"
Test #24:
score: 0
Accepted
time: 140ms
memory: 789736kb
input:
6140463
output:
869023935
result:
ok 1 number(s): "869023935"
Test #25:
score: 0
Accepted
time: 92ms
memory: 789696kb
input:
3515281
output:
989091505
result:
ok 1 number(s): "989091505"
Test #26:
score: 0
Accepted
time: 140ms
memory: 789724kb
input:
6969586
output:
539840131
result:
ok 1 number(s): "539840131"