QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#164875 | #6740. Function | mendicillin2# | AC ✓ | 327ms | 4008kb | C++17 | 1.6kb | 2023-09-05 14:21:06 | 2023-09-05 14:21:06 |
Judging History
answer
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
template <class T> int sz(T&& a) { return int(size(forward<T>(a))); }
template <class T> using vc = vector<T>;
template <class T> using vvc = vc<vc<T>>;
using ll = int64_t;
using vi = vc<int>;
mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
template <class F>
struct ycr {
F f;
template <class T> explicit ycr(T&& f_) : f(forward<T>(f_)) {}
template <class... Args> decltype(auto) operator()(Args&&... args) {
return f(ref(*this), forward<Args>(args)...);
}
};
template <class F> decltype(auto) yc(F&& f) {
return ycr<decay_t<F>>(forward<F>(f));
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int N; cin >> N;
const int n2 = int(sqrt(N));
vector<int> vs;
{
int a = N;
while (a) {
vs.push_back(a);
a = N / (N/a+1);
}
}
const int s = int(vs.size());
auto get_idx = [&](int a) -> int {
return int(a <= n2 ? s-a : N/a-1);
};
assert(vs[s-1] == 1);
const int M = 20210926;
const int MOD = 998244353;
const ll LMOD = ll(MOD) << 32;
vector<int> f(s);
for (int i = s-1; i >= 0; i--) {
int a = vs[i];
int n = N/a;
ll v = 1;
for (int k = 2; k <= M; ) {
const int cur = n*k;
if (cur > N) break;
const int which = N / cur;
// N / (N / cur)
const int nxt = N / which;
const int j = get_idx(which);
const int nxt_k = min(M, nxt / n);
v += ll(f[j]) * (nxt_k - k + 1);
if (v >= LMOD) v -= LMOD;
k = nxt_k+1;
}
f[i] = int(v % MOD);
}
cout << f[0] << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3632kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3636kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 8ms
memory: 3936kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 55ms
memory: 3836kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: 0
Accepted
time: 323ms
memory: 4008kb
input:
1000000000
output:
373787809
result:
ok 1 number(s): "373787809"
Test #12:
score: 0
Accepted
time: 321ms
memory: 3888kb
input:
999999999
output:
997616263
result:
ok 1 number(s): "997616263"
Test #13:
score: 0
Accepted
time: 327ms
memory: 3844kb
input:
999999990
output:
997615701
result:
ok 1 number(s): "997615701"
Test #14:
score: 0
Accepted
time: 323ms
memory: 3860kb
input:
999999900
output:
993928691
result:
ok 1 number(s): "993928691"
Test #15:
score: 0
Accepted
time: 327ms
memory: 3908kb
input:
999999000
output:
754532207
result:
ok 1 number(s): "754532207"
Test #16:
score: 0
Accepted
time: 327ms
memory: 3828kb
input:
999990000
output:
996592686
result:
ok 1 number(s): "996592686"
Test #17:
score: 0
Accepted
time: 323ms
memory: 3812kb
input:
999900000
output:
311678722
result:
ok 1 number(s): "311678722"
Test #18:
score: 0
Accepted
time: 323ms
memory: 3824kb
input:
999000000
output:
60462624
result:
ok 1 number(s): "60462624"
Test #19:
score: 0
Accepted
time: 324ms
memory: 3812kb
input:
990000000
output:
444576800
result:
ok 1 number(s): "444576800"
Test #20:
score: 0
Accepted
time: 302ms
memory: 3892kb
input:
900000000
output:
95615129
result:
ok 1 number(s): "95615129"
Test #21:
score: 0
Accepted
time: 3ms
memory: 3724kb
input:
1361956
output:
813433539
result:
ok 1 number(s): "813433539"
Test #22:
score: 0
Accepted
time: 9ms
memory: 3748kb
input:
7579013
output:
677659797
result:
ok 1 number(s): "677659797"
Test #23:
score: 0
Accepted
time: 6ms
memory: 3732kb
input:
8145517
output:
801509527
result:
ok 1 number(s): "801509527"
Test #24:
score: 0
Accepted
time: 8ms
memory: 3696kb
input:
6140463
output:
869023935
result:
ok 1 number(s): "869023935"
Test #25:
score: 0
Accepted
time: 5ms
memory: 3684kb
input:
3515281
output:
989091505
result:
ok 1 number(s): "989091505"
Test #26:
score: 0
Accepted
time: 9ms
memory: 3692kb
input:
6969586
output:
539840131
result:
ok 1 number(s): "539840131"