Submission #67529206


Source Code Expand

// 期待外れでいたいだなんて
// いつから願ってしまった?
// 名も知れぬほうがいいなんて
// いつからか願ってしまった

// ココロもネジ巻出して
// 意味を失ってしまった
// 何ひとつも動かせない今日と
// 押しつぶすように広がる

// 澄んだ機械仕掛けの空

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// Pragmas
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

// Namespaces
using namespace std;
using namespace __gnu_pbds;

// Data types
using si  = short int;
using ll  = long long;
using ull = unsigned long long;
using lll = __int128;
using ld  = long double;

// Pairs
using pii  = pair<int, int>;
using psi  = pair<si, si>;
using pll  = pair<ll, ll>;
using plll = pair<lll, lll>;
using pld  = pair<ld, ld>;
#define fi first
#define se second

// PBDS
template<typename Z>
using ordered_set = tree<Z, null_type, less<Z>, rb_tree_tag, tree_order_statistics_node_update>;

// Various outputs and debug
template<typename Z, typename = void> struct is_iterable : false_type {};
template<typename Z> struct is_iterable<Z, void_t<decltype(begin(declval<Z>())),decltype(end(declval<Z>()))>> : true_type {};
template<typename Z> typename enable_if<is_iterable<Z>::value&&!is_same<Z, string>::value,ostream&>::type operator<<(ostream &os, const Z &v);

template<typename Y, typename Z> ostream& operator<<(ostream &os, const pair<Y, Z> &p) {
    return os << "(" << p.fi << ", " << p.se << ")";
}
template<class TupType, size_t... I> void printTuple(ostream& os, const TupType& _tup, index_sequence<I...>) {
    os << "(";
    (..., (os << (I == 0? "" : ", ") << get<I>(_tup)));
    os << ")";
}
template<class... Z> ostream& operator<<(ostream& os, const tuple<Z...>& _tup) {
    printTuple(os, _tup, make_index_sequence<sizeof...(Z)>());
    return os;
}
template<typename Z> typename enable_if<is_iterable<Z>::value&&!is_same<Z, string>::value,ostream&>::type operator<<(ostream &os, const Z &v) {
    os << "["; 
    for (auto it = v.begin(); it != v.end();) { os << *it; if (++it != v.end()) os << ", "; }
    return os << "]";
}

#define debug(...)    logger(cout, #__VA_ARGS__, __VA_ARGS__)
#define debugV(v, x)  vlogger(cout, #v, x, v[x]);
#define rrebug(...)   logger(cerr, #__VA_ARGS__, __VA_ARGS__)
#define rrebugV(v, x) vlogger(cerr, #v, x, v[x]);
template <typename... Args>
void logger(ostream& os, string vars, Args &&...values) {
    os << vars << " = "; string delim = "";
    (..., (os << delim << values, delim = ", "));
    os << "\n";
}
template<class Y, class Z>
void vlogger(ostream& os, string var, Y idx, Z val) {
    os << var << "[" << idx << "] = " << val << "\n";
}

// Various macros
#define All(x)            x.begin(), x.end()
#define Sort(x)           sort(All(x))
#define Reverse(x)        reverse(All(x))
#define Uniqueify(x)      Sort(x); x.erase(unique(All(x)), x.end())
#define RandomSeed        chrono::steady_clock::now().time_since_epoch().count()
#define MultipleTestcases int _tc; cin >> _tc; for (int _cur_tc = 1; _cur_tc <= _tc; _cur_tc++)

// Chmin & chmax
template<typename Z> bool chmin(Z &a, Z b) { return (b < a) ? a = b, true : false; }
template<typename Z> bool chmax(Z &a, Z b) { return (b > a) ? a = b, true : false; }
 
// Modular arithmetic
template<int MOD>
class ModInt {
  public:
    int v;
    ModInt() : v(0) {}
    ModInt(long long _v) {
        v = int((-MOD < _v && _v < MOD) ? (_v) : (_v % MOD));
        if (v < 0) v += MOD;
    }
 
    friend bool operator==(const ModInt &a, const ModInt &b) { return a.v == b.v; }
    friend bool operator!=(const ModInt &a, const ModInt &b) { return a.v != b.v; }
    friend bool operator< (const ModInt &a, const ModInt &b) { return a.v <  b.v; }
    friend bool operator<=(const ModInt &a, const ModInt &b) { return a.v <= b.v; }
    friend bool operator> (const ModInt &a, const ModInt &b) { return a.v >  b.v; }
    friend bool operator>=(const ModInt &a, const ModInt &b) { return a.v >= b.v; }
 
    ModInt &operator+=(const ModInt &a) { v = (long long)(v + a.v) % MOD; return *this; }
    ModInt &operator-=(const ModInt &a) { v = (long long)(v - a.v + MOD) % MOD; return *this; }
    ModInt &operator*=(const ModInt &a) { v = 1ll * v * a.v % MOD; return *this; }
    ModInt &operator/=(const ModInt &a) { return (*this) *= inverse(a); }
 
    friend ModInt pow(ModInt a, long long x) {
        ModInt res = 1;
        for (; x; x /= 2, a *= a) if (x & 1) res *= a;
        return res;
    }
    friend ModInt inverse(ModInt a) { return pow(a, MOD - 2); }
 
    ModInt operator+ () const { return ModInt( v); }
    ModInt operator- () const { return ModInt(-v); }
    ModInt operator++() const { return *this += 1; }
    ModInt operator--() const { return *this -= 1; }
 
    friend ModInt operator+(ModInt a, const ModInt &b) { return a += b; }
    friend ModInt operator-(ModInt a, const ModInt &b) { return a -= b; }
    friend ModInt operator*(ModInt a, const ModInt &b) { return a *= b; }
    friend ModInt operator/(ModInt a, const ModInt &b) { return a /= b; }
 
    friend istream &operator>>(istream &is, ModInt &v) { return is >> v.v; }
    friend ostream &operator<<(ostream &os, const ModInt &v) { return os << v.v; }
};
const int ModA = 998244353;
const int ModC = 1e9 + 7;
using MintA    = ModInt<ModA>;
using MintC    = ModInt<ModC>;

// Other constants
const ll INF  = 1e18;
const ll iINF = 1e9;
const ld EPS  = 1e-9;
const ld iEPS = 1e-6;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    ll n;
    cin >> n;

    MintA n_mod = n;
    MintA ans = n_mod * (n_mod + 1) / 2;

    ll cur = 1;
    while (cur <= n) {
        ll l = cur, r = n, h = -1;
        ll pivot = n / cur;
        while (l <= r) {
            ll m = (l + r) / 2;
            if (n / m == pivot) {
                h = m;
                l = m + 1;
            } else {
                r = m - 1;
            }
        }
        // rrebug(cur, h);
        ans -= MintA(pivot) * MintA(h - cur + 1);
        cur = h + 1;
    }

    cout << ans << "\n";
}

// dibisakan

Submission Info

Submission Time
Task E - Count A%B=C
User Zanite
Language C++ 20 (gcc 12.2)
Score 475
Code Size 6419 Byte
Status AC
Exec Time 248 ms
Memory 3608 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 56
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt, 01-52.txt, 01-53.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 1 ms 3328 KiB
00-sample-02.txt AC 1 ms 3408 KiB
00-sample-03.txt AC 147 ms 3388 KiB
01-01.txt AC 1 ms 3400 KiB
01-02.txt AC 1 ms 3464 KiB
01-03.txt AC 1 ms 3440 KiB
01-04.txt AC 1 ms 3396 KiB
01-05.txt AC 1 ms 3412 KiB
01-06.txt AC 1 ms 3524 KiB
01-07.txt AC 1 ms 3332 KiB
01-08.txt AC 1 ms 3396 KiB
01-09.txt AC 1 ms 3604 KiB
01-10.txt AC 1 ms 3400 KiB
01-11.txt AC 1 ms 3440 KiB
01-12.txt AC 1 ms 3608 KiB
01-13.txt AC 1 ms 3480 KiB
01-14.txt AC 1 ms 3408 KiB
01-15.txt AC 247 ms 3448 KiB
01-16.txt AC 247 ms 3412 KiB
01-17.txt AC 248 ms 3468 KiB
01-18.txt AC 248 ms 3464 KiB
01-19.txt AC 246 ms 3460 KiB
01-20.txt AC 240 ms 3476 KiB
01-21.txt AC 245 ms 3472 KiB
01-22.txt AC 238 ms 3600 KiB
01-23.txt AC 235 ms 3456 KiB
01-24.txt AC 243 ms 3388 KiB
01-25.txt AC 244 ms 3392 KiB
01-26.txt AC 239 ms 3324 KiB
01-27.txt AC 240 ms 3460 KiB
01-28.txt AC 1 ms 3348 KiB
01-29.txt AC 1 ms 3444 KiB
01-30.txt AC 1 ms 3332 KiB
01-31.txt AC 1 ms 3328 KiB
01-32.txt AC 1 ms 3424 KiB
01-33.txt AC 1 ms 3420 KiB
01-34.txt AC 3 ms 3420 KiB
01-35.txt AC 3 ms 3476 KiB
01-36.txt AC 5 ms 3420 KiB
01-37.txt AC 5 ms 3412 KiB
01-38.txt AC 9 ms 3596 KiB
01-39.txt AC 10 ms 3324 KiB
01-40.txt AC 13 ms 3400 KiB
01-41.txt AC 16 ms 3476 KiB
01-42.txt AC 165 ms 3456 KiB
01-43.txt AC 180 ms 3528 KiB
01-44.txt AC 42 ms 3472 KiB
01-45.txt AC 232 ms 3392 KiB
01-46.txt AC 76 ms 3460 KiB
01-47.txt AC 2 ms 3424 KiB
01-48.txt AC 99 ms 3312 KiB
01-49.txt AC 32 ms 3424 KiB
01-50.txt AC 138 ms 3456 KiB
01-51.txt AC 167 ms 3472 KiB
01-52.txt AC 25 ms 3608 KiB
01-53.txt AC 196 ms 3520 KiB