結果

問題 No.2750 Number of Prime Factors
ユーザー hiromi_ayasehiromi_ayase
提出日時 2024-05-10 21:33:31
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 6,052 ms
コンパイル使用メモリ 309,568 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-10 21:33:52
合計ジャッジ時間 6,874 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO                \
  ios::sync_with_stdio(false); \
  cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;

vector<i64> erathosthenes(i64 N) {
  vector<i64> is_prime(N + 1, 1);
  is_prime[0] = is_prime[1] = 0;

  vector<i64> ret;
  for (i64 i = 2; i <= N; i++) {

    if (!is_prime[i]) continue;
    ret.push_back(i);
    for (i64 j = i; j <= N; j += i) {
      is_prime[j] = 0;
    }
  }

  return ret;
}


int main() {
  FAST_IO
  auto ans = 0LL;

  __int128_t N;
  i64 n;
  cin >> n;
  N = n;

  auto primes = erathosthenes(10000);

  __int128_t x = 1;
  for (auto p : primes) {
    if (x * p <= N) {
      x *= p;
      ans++;
    } else {
      break;
    }
  }

  cout << ans << endl;
}
0