結果

問題 No.2480 Sequence Sum
ユーザー haihamabossuhaihamabossu
提出日時 2023-09-22 22:12:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 500 ms
コード長 1,117 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 116,220 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-04 12:34:30
合計ジャッジ時間 1,914 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 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 <algorithm>
#include <map>
#include <vector>

namespace cplib {

std::map<long long, long long> prime_factorization(long long n) {
  std::map<long long, long long> res;
  if (n < 2) {
    return res;
  }
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n > 1) {
    res[n]++;
  }
  return res;
}

std::vector<long long> divisors(long long n) {
  std::vector<long long> res;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      long long j = n / i;
      res.emplace_back(i);
      if (i != j) {
        res.emplace_back(j);
      }
    }
  }
  std::sort(res.begin(), res.end());
  return res;
}

}

#include <algorithm>
#include <iostream>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

void solve() {
  long long n;
  cin >> n;
  if (n <= 2) {
    cout << 0 << '\n';
  }
  auto ds = cplib::divisors(n);
  cout << n - ds.size() << '\n';
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int T = 1;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
0