QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#335706 | #6740. Function | ucup-team1198 | TL | 144ms | 5236kb | C++14 | 1.4kb | 2024-02-23 20:05:49 | 2024-02-23 20:05:49 |
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 = 200000;
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: 4ms
memory: 5188kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 4ms
memory: 5236kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 3ms
memory: 5232kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 4ms
memory: 5196kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 0ms
memory: 5236kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 4ms
memory: 5168kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 3ms
memory: 5112kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 4ms
memory: 5132kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 6ms
memory: 5176kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 144ms
memory: 5196kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: -100
Time Limit Exceeded
input:
1000000000