QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#149135 | #6740. Function | UFRJ | RE | 1ms | 3496kb | C++20 | 2.7kb | 2023-08-24 02:19:20 | 2023-08-24 02:19:23 |
Judging History
answer
#include<bits/stdc++.h>
using 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; }
};
using lint = int64_t;
using mod = modnum<998244353>;
unordered_map<lint, mod> memo;
mod solve(lint x){
if(x == 1) return 1;
if(memo.count(x)) return memo[x];
mod &ans = memo[x];
ans = 1;
for(lint a =1, b; a<=x; a=b+1){
b = x / (x/a);
lint A = max<lint>(2, a);
lint B = min<lint>(b, 20210926);
assert(A <= B);
ans += ( mod(B-A+1) )* solve(x/a);
}
return ans;
}
int main(){
lint n; cin>>n;
cout<<solve(n)<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3496kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: -100
Dangerous Syscalls
input:
2