QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#335696 | #6740. Function | ucup-team1198 | AC ✓ | 352ms | 42752kb | C++20 | 1.4kb | 2024-02-23 19:52:33 | 2024-02-23 19:52:33 |
Judging History
answer
#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
const int MOD = 998244353;
int add(int a, int b) {
return a + b >= MOD ? a + b - MOD : a + b;
}
int sub(int a, int b) {
return a >= b ? a - b : a + MOD - b;
}
int mul(int a, int b) {
return (1ll * a * b) % MOD;
}
int pw(int x, int n) {
int res = 1;
while (n) {
if (n % 2 == 0) {
x = mul(x, x);
n /= 2;
} else {
res = mul(res, x);
--n;
}
}
return res;
}
const int K = 20210926;
const int MAXN = 5000000;
int vals[MAXN];
int pref_sums[MAXN];
int get_ans(int n) {
if (n < MAXN)
return pref_sums[n];
int ans = 1;
int left = 2;
while (left <= n && left <= K) {
int right = min(K + 1, (n / (n / left)) + 1);
ans = add(ans, mul(get_ans(n / left), (right - left) % MOD));
left = right;
}
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
vals[1] = 1;
for (int i = 1; i < MAXN; ++i) {
pref_sums[i] = add(pref_sums[i - 1], vals[i]);
for (int j = 2 * i; j < MAXN; j += i)
vals[j] = add(vals[j], vals[i]);
}
int n;
cin >> n;
cout << get_ans(n) << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 197ms
memory: 42692kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 195ms
memory: 42640kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 203ms
memory: 42644kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 198ms
memory: 42736kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 195ms
memory: 42696kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 197ms
memory: 42648kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 204ms
memory: 42652kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 217ms
memory: 42692kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 207ms
memory: 42668kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 203ms
memory: 42692kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: 0
Accepted
time: 339ms
memory: 42752kb
input:
1000000000
output:
373787809
result:
ok 1 number(s): "373787809"
Test #12:
score: 0
Accepted
time: 341ms
memory: 42684kb
input:
999999999
output:
997616263
result:
ok 1 number(s): "997616263"
Test #13:
score: 0
Accepted
time: 352ms
memory: 42700kb
input:
999999990
output:
997615701
result:
ok 1 number(s): "997615701"
Test #14:
score: 0
Accepted
time: 341ms
memory: 42696kb
input:
999999900
output:
993928691
result:
ok 1 number(s): "993928691"
Test #15:
score: 0
Accepted
time: 346ms
memory: 42636kb
input:
999999000
output:
754532207
result:
ok 1 number(s): "754532207"
Test #16:
score: 0
Accepted
time: 350ms
memory: 42632kb
input:
999990000
output:
996592686
result:
ok 1 number(s): "996592686"
Test #17:
score: 0
Accepted
time: 351ms
memory: 42612kb
input:
999900000
output:
311678722
result:
ok 1 number(s): "311678722"
Test #18:
score: 0
Accepted
time: 336ms
memory: 42752kb
input:
999000000
output:
60462624
result:
ok 1 number(s): "60462624"
Test #19:
score: 0
Accepted
time: 332ms
memory: 42644kb
input:
990000000
output:
444576800
result:
ok 1 number(s): "444576800"
Test #20:
score: 0
Accepted
time: 320ms
memory: 42660kb
input:
900000000
output:
95615129
result:
ok 1 number(s): "95615129"
Test #21:
score: 0
Accepted
time: 200ms
memory: 42692kb
input:
1361956
output:
813433539
result:
ok 1 number(s): "813433539"
Test #22:
score: 0
Accepted
time: 194ms
memory: 42680kb
input:
7579013
output:
677659797
result:
ok 1 number(s): "677659797"
Test #23:
score: 0
Accepted
time: 199ms
memory: 42608kb
input:
8145517
output:
801509527
result:
ok 1 number(s): "801509527"
Test #24:
score: 0
Accepted
time: 212ms
memory: 42632kb
input:
6140463
output:
869023935
result:
ok 1 number(s): "869023935"
Test #25:
score: 0
Accepted
time: 201ms
memory: 42688kb
input:
3515281
output:
989091505
result:
ok 1 number(s): "989091505"
Test #26:
score: 0
Accepted
time: 196ms
memory: 42632kb
input:
6969586
output:
539840131
result:
ok 1 number(s): "539840131"