結果

問題 No.106 素数が嫌い!2
ユーザー ninoinuininoinui
提出日時 2020-07-18 05:14:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 759 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 205,708 KB
実行使用メモリ 25,756 KB
最終ジャッジ日時 2023-08-20 16:33:38
合計ジャッジ時間 7,698 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 137 ms
24,880 KB
testcase_02 AC 130 ms
24,940 KB
testcase_03 AC 140 ms
25,060 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 135 ms
24,932 KB
testcase_09 AC 135 ms
24,816 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 141 ms
25,124 KB
testcase_14 AC 141 ms
25,116 KB
testcase_15 AC 132 ms
24,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr long lim = 200001;
vector<vector<int>> pr(lim), id(lim);
vector<bool> is_pr(lim, true);

void all_fac() {
  is_pr.at(0) = 0;
  is_pr.at(1) = 0;
  for (int i = 2; i < lim; i++) {
    if (is_pr.at(i)) {
      pr.at(i).push_back(i);
      id.at(i).push_back(1);
      for (int j = 2 * i; j < lim; j += i) {
        is_pr.at(j) = false;
        int cnt = 0;
        int nw = j;
        while(nw % i == 0) {
          nw /= i;
          cnt++;
        }
        pr.at(j).push_back(i);
        id.at(j).push_back(cnt);
      }
    }
  }
}

int main() {
  all_fac();
  int N, K;
  cin >> N >> K;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (pr.at(i).size() >= K) ans++;
  }
  cout << ans << "\n";
}
0