QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140969 | #6740. Function | cciafrino# | TL | 374ms | 4400kb | C++20 | 2.7kb | 2023-08-17 02:12:44 | 2023-08-17 02:12:48 |
Judging History
answer
#include<bits/stdc++.h>
namespace std {
int minv(int a, int m) {
a %= m; assert(a);
return a == 1 ? 1 : int(m - int64_t(minv(m, a)) * m / a);
}
template<unsigned M_> struct modnum {
static constexpr unsigned M = M_;
using ll = int64_t; using ull = uint64_t; unsigned x;
modnum& norm(unsigned a) { x = a < M ? a : a - M; return *this; }
constexpr modnum(ll a = 0U) : x(unsigned((a %= ll(M)) < 0 ? a + ll(M) : a)) {}
explicit operator int() const { return x; }
modnum& operator+=(const modnum& a) { return norm(x + a.x); }
modnum& operator-=(const modnum& a) { return norm(x - a.x + M); }
modnum& operator*=(const modnum& a) { x = unsigned(ull(x) * a.x % M); return *this; }
modnum& operator/=(const modnum& a) { return (*this *= a.inv()); }
modnum operator+(const modnum& a) const { return (modnum(*this) += a); }
modnum operator-(const modnum& a) const { return (modnum(*this) -= a); }
modnum operator*(const modnum& a) const { return (modnum(*this) *= a); }
modnum operator/(const modnum& a) const { return (modnum(*this) /= a); }
template<typename T> friend modnum operator+(T a, const modnum& b) { return (modnum(a) += b); }
template<typename T> friend modnum operator-(T a, const modnum& b) { return (modnum(a) -= b); }
template<typename T> friend modnum operator*(T a, const modnum& b) { return (modnum(a) *= b); }
template<typename T> friend modnum operator/(T a, const modnum& b) { return (modnum(a) /= b); }
modnum operator+() const { return *this; }
modnum operator-() const { return modnum() - *this; }
modnum pow(ll e) const {
if (e < 0) return inv().pow(-e);
modnum b = x, xe = 1U;
for (; e; e >>= 1) { if (e & 1) xe *= b; b *= b; }
return xe;
}
modnum inv() const { return minv(x, M); }
friend modnum inv(const modnum& a) { return a.inv(); }
explicit operator bool() const { return x; }
friend bool operator==(const modnum& a, const modnum& b) { return a.x == b.x; }
friend bool operator!=(const modnum& a, const modnum& b) { return a.x != b.x; }
friend ostream &operator<<(ostream& os, const modnum& a) { return os << a.x; }
friend istream &operator>>(istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
}; }
int main() {
using namespace std;
cin.tie(nullptr)->sync_with_stdio(false);
int N; cin >> N;
const int lo = 2, hi = 20210926;
using num = modnum<998244353U>;
map<int, num> mapa;
auto rec = [&](auto&& self, int X) -> num {
if (mapa.count(X) > 0) return mapa[X];
num S = 1;
for (int a = 1, b; a <= X; a = b+1) {
b = X / (X / a);
if (max(lo, a) <= min(hi, b)) {
int mi = max(lo, a), ma = min(hi, b);
S += num(ma - mi + 1) * self(self, X/a);
}
}
return mapa[X] = S;
};
cout << rec(rec, N) << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3448kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
100
output:
949
result:
ok 1 number(s): "949"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
10
output:
19
result:
ok 1 number(s): "19"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
1000
output:
48614
result:
ok 1 number(s): "48614"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3504kb
input:
10000
output:
2602393
result:
ok 1 number(s): "2602393"
Test #7:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
100000
output:
139804054
result:
ok 1 number(s): "139804054"
Test #8:
score: 0
Accepted
time: 6ms
memory: 3660kb
input:
1000000
output:
521718285
result:
ok 1 number(s): "521718285"
Test #9:
score: 0
Accepted
time: 58ms
memory: 3784kb
input:
10000000
output:
503104917
result:
ok 1 number(s): "503104917"
Test #10:
score: 0
Accepted
time: 374ms
memory: 4400kb
input:
100000000
output:
198815604
result:
ok 1 number(s): "198815604"
Test #11:
score: -100
Time Limit Exceeded
input:
1000000000