結果
問題 | No.2480 Sequence Sum |
ユーザー | rniya |
提出日時 | 2023-09-22 21:29:28 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 500 ms |
コード長 | 4,326 bytes |
コンパイル時間 | 1,900 ms |
コンパイル使用メモリ | 206,092 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-26 14:33:23 |
合計ジャッジ時間 | 2,435 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 1 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h>#ifdef LOCAL#include <debug.hpp>#else#define debug(...) void(0)#endifnamespace elementary_math {template <typename T> std::vector<T> divisor(T n) {std::vector<T> res;for (T i = 1; i * i <= n; i++) {if (n % i == 0) {res.emplace_back(i);if (i * i != n) res.emplace_back(n / i);}}return res;}template <typename T> std::vector<std::pair<T, int>> prime_factor(T n) {std::vector<std::pair<T, int>> res;for (T p = 2; p * p <= n; p++) {if (n % p == 0) {res.emplace_back(p, 0);while (n % p == 0) {res.back().second++;n /= p;}}}if (n > 1) res.emplace_back(n, 1);return res;}std::vector<int> osa_k(int n) {std::vector<int> min_factor(n + 1, 0);for (int i = 2; i <= n; i++) {if (min_factor[i]) continue;for (int j = i; j <= n; j += i) {if (!min_factor[j]) {min_factor[j] = i;}}}return min_factor;}std::vector<int> prime_factor(const std::vector<int>& min_factor, int n) {std::vector<int> res;while (n > 1) {res.emplace_back(min_factor[n]);n /= min_factor[n];}return res;}long long modpow(long long x, long long n, long long mod) {assert(0 <= n && 1 <= mod && mod < (1LL << 31));if (mod == 1) return 0;x %= mod;long long res = 1;while (n > 0) {if (n & 1) res = res * x % mod;x = x * x % mod;n >>= 1;}return res;}long long extgcd(long long a, long long b, long long& x, long long& y) {long long d = a;if (b != 0) {d = extgcd(b, a % b, y, x);y -= (a / b) * x;} elsex = 1, y = 0;return d;}long long inv_mod(long long a, long long mod) {assert(1 <= mod);long long x, y;if (extgcd(a, mod, x, y) != 1) return -1;return (mod + x % mod) % mod;}template <typename T> T euler_phi(T n) {auto pf = prime_factor(n);T res = n;for (const auto& p : pf) {res /= p.first;res *= p.first - 1;}return res;}std::vector<int> euler_phi_table(int n) {std::vector<int> res(n + 1, 0);iota(res.begin(), res.end(), 0);for (int i = 2; i <= n; i++) {if (res[i] != i) continue;for (int j = i; j <= n; j += i) res[j] = res[j] / i * (i - 1);}return res;}// minimum i > 0 s.t. x^i \equiv 1 \pmod{m}template <typename T> T order(T x, T m) {T n = euler_phi(m);auto cand = divisor(n);sort(cand.begin(), cand.end());for (auto& i : cand) {if (modpow(x, i, m) == 1) {return i;}}return -1;}template <typename T> std::vector<std::tuple<T, T, T>> quotient_ranges(T n) {std::vector<std::tuple<T, T, T>> res;T m = 1;for (; m * m <= n; m++) res.emplace_back(m, m, n / m);for (; m >= 1; m--) {T l = n / (m + 1) + 1, r = n / m;if (l <= r and std::get<1>(res.back()) < l) res.emplace_back(l, r, n / l);}return res;}} // namespace elementary_mathusing namespace std;typedef long long ll;#define all(x) begin(x), end(x)constexpr int INF = (1 << 30) - 1;constexpr long long IINF = (1LL << 60) - 1;constexpr int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};template <class T> istream& operator>>(istream& is, vector<T>& v) {for (auto& x : v) is >> x;return is;}template <class T> ostream& operator<<(ostream& os, const vector<T>& v) {auto sep = "";for (const auto& x : v) os << exchange(sep, " ") << x;return os;}template <class T, class U = T> bool chmin(T& x, U&& y) { return y < x and (x = forward<U>(y), true); }template <class T, class U = T> bool chmax(T& x, U&& y) { return x < y and (x = forward<U>(y), true); }template <class T> void mkuni(vector<T>& v) {sort(begin(v), end(v));v.erase(unique(begin(v), end(v)), end(v));}template <class T> int lwb(const vector<T>& v, const T& x) { return lower_bound(begin(v), end(v), x) - begin(v); }int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int N;cin >> N;int ans = N - elementary_math::divisor(N).size();cout << ans << '\n';return 0;}