結果

問題 No.2480 Sequence Sum
ユーザー AnchorBluesAnchorBlues
提出日時 2023-09-28 23:05:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 500 ms
コード長 1,886 bytes
コンパイル時間 2,037 ms
コンパイル使用メモリ 205,668 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-04 12:35:39
合計ジャッジ時間 2,871 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;

const ll INF = 1LL << 60;

template <class T>
void chmax(T& a, T b) {
    if (b > a) a = b;
}
template <class T>
void chmin(T& a, T b) {
    if (b < a) a = b;
}

template <typename T, typename S>
std::ostream& operator<<(std::ostream& os, const pair<T, S>& x) noexcept {
    return os << "(" << x.first << ", " << x.second << ")";
}

template <typename T>
void print_vector(vector<T> a) {
    cout << '[';
    for (int i = 0; i < a.size(); i++) {
        cout << a[i];
        if (i != a.size() - 1) {
            cout << ", ";
        }
    }
    cout << ']' << endl;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll ceilll(ll x, ll y) { return (x + y - 1) / y; }
ll mod(ll x, ll y) { return (x + 10000000) % y; }

// 約数全列挙
vector<ll> all_divisors(ll K) {
    vector<ll> ret;
    for (ll i = 1; i * i <= K; i++) {
        if (K % i != 0) continue;
        ret.push_back(i);
        if (i * i != K) ret.push_back(K / i);
    }
    return ret;
}

// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N) {
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

void solve() {
    ll N;
    cin >> N;
    auto ds = all_divisors(N);
    std::cout << N - ds.size() << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}
0