結果
問題 | No.1157 Many Quotients easy |
ユーザー |
![]() |
提出日時 | 2025-02-18 11:50:49 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 12,534 bytes |
コンパイル時間 | 3,999 ms |
コンパイル使用メモリ | 293,448 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-18 11:50:55 |
合計ジャッジ時間 | 5,156 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#line 1 "/opt/library/template.hpp"#include <bits/stdc++.h>using namespace std;using ll = long long;using i64 = long long;using u32 = unsigned int;using u64 = unsigned long long;using i128 = __int128;using u128 = unsigned __int128;using f128 = __float128;template <class T>constexpr T infty = 0;template <>constexpr int infty<int> = 1'000'001'000;template <>constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;template <>constexpr u32 infty<u32> = infty<int>;template <>constexpr u64 infty<u64> = infty<ll>;template <>constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;template <>constexpr double infty<double> = infty<ll>;template <>constexpr long double infty<long double> = infty<ll>;#define inf infty<ll>using pi = pair<ll, ll>;using vi = vector<ll>;using vvi = vector<vector<ll>>;template <class T>using vc = vector<T>;template <class T>using vvc = vector<vc<T>>;template <class T>using vvvc = vector<vvc<T>>;template <class T>using vvvvc = vector<vvvc<T>>;template <class T>using vvvvvc = vector<vvvvc<T>>;template <class T>using pq = priority_queue<T>;template <class T>using pqg = priority_queue<T, vector<T>, greater<T>>;#define vv(type, name, h, ...) \vector<vector<type>> name(h, vector<type>(__VA_ARGS__))#define vvv(type, name, h, w, ...) \vector<vector<vector<type>>> name( \h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))#define vvvv(type, name, a, b, c, ...) \vector<vector<vector<vector<type>>>> name( \a, vector<vector<vector<type>>>( \b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))#define rep1(a) for (ll _ = 0; _ < (ll)(a); ++_)#define rep2(i, a) for (ll i = 0; i < (ll)(a); ++i)#define rep3(i, a, b) for (ll i = a; i < (ll)(b); ++i)#define rep4(i, a, b, c) for (ll i = a; i < (ll)(b); i += (c))#define rrep1(a) for (ll i = (a)-1; i >= (ll)(0); --i)#define rrep2(i, a) for (ll i = (a)-1; i >= (ll)(0); --i)#define rrep3(i, a, b) for (ll i = (b)-1; i >= (ll)(a); --i)#define rrep4(i, a, b, c) for (ll i = (b)-1; i >= (ll)(a); i -= (c))#define overload4(a, b, c, d, e, ...) e#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)#define all(x) (x).begin(),(x).end()#define len(x) (ll)(x.size())#define elif else if#define bit(x, i) (((x)>>(i))&1)#define eb emplace_back#define mp make_pair#define mt make_tuple#define fi first#define se second#define stoi stoll#define abs llabs#define MIN(v) *min_element(all(v))#define MAX(v) *max_element(all(v))#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))#define UNIQUE(x) \sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()ll popcnt(ll x) { return __builtin_popcountll(x); }ll popcnt(u64 x) { return __builtin_popcountll(x); }ll popcnt_mod_2(ll x) { return __builtin_parityll(x); }ll popcnt_mod_2(u64 x) { return __builtin_parityll(x); }ll topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }ll topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }ll lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }ll lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }template <typename T>T floor(T a, T b) {return a / b - (a % b && (a ^ b) < 0);}template <typename T>T ceil(T x, T y) {return floor(x + y - 1, y);}template <typename T>T bmod(T x, T y) {return x - y * floor(x, y);}template <typename T>pair<T, T> divmod(T x, T y) {T q = floor(x, y);return {q, x - q * y};}template<typename T> T SUM(const vector<T> &A) {T s = 0; for (auto &&a: A) s += a;return s;}template <typename T>T POP(queue<T> &que) {T a = que.front();que.pop();return a;}template <typename T>T POP(deque<T> &que) {T a = que.front();que.pop_front();return a;}template <typename T>T POP(pq<T> &que) {T a = que.top();que.pop();return a;}template <typename T>T POP(pqg<T> &que) {T a = que.top();que.pop();return a;}template <typename T>T POP(vc<T> &que) {T a = que.back();que.pop_back();return a;}template <typename F>ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {if (check_ok) assert(check(ok));while (abs(ok - ng) > 1) {auto x = (ng + ok) / 2;(check(x) ? ok : ng) = x;}return ok;}template <typename F>f128 binary_search_real(F check, f128 ok, f128 ng, ll iter = 100) {rep(iter) {f128 x = (ok + ng) / 2;(check(x) ? ok : ng) = x;}return (ok + ng) / 2;}// ? は -1vc<int> s_to_vi(const string &S, char first_char) {vc<int> A(S.size());rep(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }return A;}template <typename T, typename U>vc<T> cumsum(vc<U> &A, ll off = 1) {ll N = A.size();vc<T> B(N + 1);rep(i, N) { B[i + 1] = B[i] + A[i]; }if (off == 0) B.erase(B.begin());return B;}// stable sorttemplate <typename T>vi argsort(const vector<T> &A) {vi ids(len(A));iota(all(ids), 0);sort(all(ids),[&](ll i, ll j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });return ids;}// A[I[0]], A[I[1]], ...template <typename T>vc<T> rearrange(const vc<T> &A, const vi &I) {vc<T> B(len(I));rep(i, len(I)) B[i] = A[I[i]];return B;}template<typename T> inline bool chmax(T &a, T b) {return ((a<b)?(a=b,true):(false));}template<typename T> inline bool chmin(T &a, T b) {return ((a>b)?(a=b,true):(false));}inline void wt(const char c) { cout << c; }inline void wt(const string s) { cout << s; }inline void wt(const char *s) { cout << s; }template <typename T>void wt_integer(T x) {cout << (x);}template <typename T>void wt_real(T x) {cout << fixed << setprecision(15) << (long double)(x);}template <typename T>void wt_integer128(T x) {char buf[64];char *d = end(buf);d--; *d = '\0';__uint128_t tmp = ((x < 0)? -x : x);do {d--; *d = char(tmp%10 + '0'); tmp /= 10;} while (tmp);if (x < 0) {d--; *d = '-';}cout << d;}inline void wt(int x) { wt_integer(x); }inline void wt(ll x) { wt_integer(x); }inline void wt(i128 x) { wt_integer128(x); }inline void wt(u32 x) { wt_integer(x); }inline void wt(u64 x) { wt_integer(x); }inline void wt(u128 x) { wt_integer128(x); }inline void wt(double x) { wt_real(x); }inline void wt(long double x) { wt_real(x); }inline void wt(f128 x) { wt_real(x); }template <class T, class U>void wt(const pair<T, U> val) {wt(val.first); wt(' '); wt(val.second);}template <size_t N = 0, typename T>void wt_tuple(const T t) {if constexpr (N < std::tuple_size<T>::value) {if constexpr (N > 0) { wt(' '); }const auto x = std::get<N>(t);wt(x);wt_tuple<N + 1>(t);}}template <class... T>void wt(tuple<T...> tpl) {wt_tuple(tpl);}template <class T, size_t S>void wt(const array<T, S> val) {auto n = val.size();for (size_t i = 0; i < n; i++) {if (i) wt(' ');wt(val[i]);}}template <class T>void wt(const vector<T> val) {auto n = val.size();for (size_t i = 0; i < n; i++) {if (i) wt(' ');wt(val[i]);}}void print() { wt('\n'); }template <class Head, class... Tail>void print(Head &&head, Tail &&... tail) {wt(head);if (sizeof...(Tail)) wt(' ');print(forward<Tail>(tail)...);}void YES(bool t = 1) { print(t ? "YES" : "NO"); }void NO(bool t = 1) { YES(!t); }void Yes(bool t = 1) { print(t ? "Yes" : "No"); }void No(bool t = 1) { Yes(!t); }void yes(bool t = 1) { print(t ? "yes" : "no"); }void no(bool t = 1) { yes(!t); }void onez(bool t = 1) { print(t ? 1 : 0); }#define endl '\n'#define dump(x) {cerr << #x " = " << x << '\n';}#line 2 "/opt/library/nt/factor.hpp"#line 2 "/opt/library/random/base.hpp"u64 RNG_64() {static uint64_t x_= uint64_t(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count())* 10150724397891781847ULL;x_ ^= x_ << 7;return x_ ^= x_ >> 9;}u64 RNG(u64 lim) { return RNG_64() % lim; }ll RNG(ll l, ll r) { return l + RNG_64() % (r - l); }#line 2 "/opt/library/mod/mongomery_modint.hpp"// odd mod.// x の代わりに rx を持つtemplate <ll id, typename U1, typename U2>struct Mongomery_modint {using mint = Mongomery_modint;inline static U1 m, r, n2;static constexpr ll W = numeric_limits<U1>::digits;static void set_mod(U1 mod) {assert(mod & 1 && mod <= U1(1) << (W - 2));m = mod, n2 = -U2(m) % m, r = m;rep(5) r *= 2 - m * r;r = -r;assert(r * m == U1(-1));}static U1 reduce(U2 b) { return (b + U2(U1(b) * r) * m) >> W; }U1 x;Mongomery_modint() : x(0) {}Mongomery_modint(U1 x) : x(reduce(U2(x) * n2)){};U1 val() const {U1 y = reduce(x);return y >= m ? y - m : y;}mint &operator+=(mint y) {x = ((x += y.x) >= m ? x - m : x);return *this;}mint &operator-=(mint y) {x -= (x >= y.x ? y.x : y.x - m);return *this;}mint &operator*=(mint y) {x = reduce(U2(x) * y.x);return *this;}mint operator+(mint y) const { return mint(*this) += y; }mint operator-(mint y) const { return mint(*this) -= y; }mint operator*(mint y) const { return mint(*this) *= y; }bool operator==(mint y) const {return (x >= m ? x - m : x) == (y.x >= m ? y.x - m : y.x);}bool operator!=(mint y) const { return not operator==(y); }mint pow(ll n) const {assert(n >= 0);mint y = 1, z = *this;for (; n; n >>= 1, z *= z)if (n & 1) y *= z;return y;}};template<ll id>using Mongomery_modint_32 = Mongomery_modint<id, u32, u64>;template<ll id>using Mongomery_modint_64 = Mongomery_modint<id, u64, u128>;#line 3 "/opt/library/nt/primetest.hpp"bool primetest(const u64 x) {assert(x < u64(1) << 62);if (x == 2 or x == 3 or x == 5 or x == 7) return true;if (x % 2 == 0 or x % 3 == 0 or x % 5 == 0 or x % 7 == 0) return false;if (x < 121) return x > 1;const u64 d = (x - 1) >> lowbit(x - 1);using mint = Mongomery_modint_64<202311020>;mint::set_mod(x);const mint one(u64(1)), minus_one(x - 1);auto ok = [&](u64 a) -> bool {auto y = mint(a).pow(d);u64 t = d;while (y != one && y != minus_one && t != x - 1) y *= y, t <<= 1;if (y != minus_one && t % 2 == 0) return false;return true;};if (x < (u64(1) << 32)) {for (u64 a: {2, 7, 61})if (!ok(a)) return false;} else {for (u64 a: {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) {if (!ok(a)) return false;}}return true;}#line 5 "/opt/library/nt/factor.hpp"template <typename mint>ll rho(ll n, ll c) {assert(n > 1);const mint cc(c);auto f = [&](mint x) { return x * x + cc; };mint x = 1, y = 2, z = 1, q = 1;ll g = 1;const ll m = 1LL << (__lg(n) / 5);for (ll r = 1; g == 1; r <<= 1) {x = y;rep(r) y = f(y);for (ll k = 0; k < r && g == 1; k += m) {z = y;rep(min(m, r - k)) y = f(y), q *= x - y;g = gcd(q.val(), n);}}if (g == n) do {z = f(z);g = gcd((x - z).val(), n);} while (g == 1);return g;}ll find_prime_factor(ll n) {assert(n > 1);if (primetest(n)) return n;rep(100) {ll m = 0;if (n < (1 << 30)) {using mint = Mongomery_modint_32<20231025>;mint::set_mod(n);m = rho<mint>(n, RNG(0, n));} else {using mint = Mongomery_modint_64<20231025>;mint::set_mod(n);m = rho<mint>(n, RNG(0, n));}if (primetest(m)) return m;n = m;}assert(0);return -1;}vc<pi> factor(ll n) {assert(n >= 1);vc<pi> pf;rep(p, 2, 100) {if (p * p > n) break;if (n % p == 0) {ll e = 0;do { n /= p, e++; } while (n % p == 0);pf.eb(p, e);}}while (n > 1) {ll p = find_prime_factor(n);ll e = 0;do { n /= p, e++; } while (n % p == 0);pf.eb(p, e);}sort(all(pf));return pf;}vc<pi> factor_by_lpf(ll n, vc<ll>& lpf) {vc<pi> res;while (n > 1) {ll p = lpf[n];ll e = 0;while (n % p == 0) {n /= p;e++;}res.eb(p, e);}return res;}#line 3 "main.cpp"int solve();int main() {cin.tie(nullptr);ios_base::sync_with_stdio(false);ll T = 1;while (!solve()) if (--T == 0) break;return 0;}int solve() {ll N;cin >> N;set<ll> S;rep(i, 1, N+1) S.emplace(N/i);print(len(S));return 0;}