結果

問題 No.106 素数が嫌い!2
ユーザー kuisibakuisiba
提出日時 2016-10-17 16:32:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 502 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 54,488 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-05-02 03:10:54
合計ジャッジ時間 13,086 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdint>

using namespace std;

int pf(int a) {
  int count = 0;
  if (a == 2) return 1;
  if (a == 3) return 1;
  for (int i = 2; i <= a; i++) {
    if (a % i == 0) {
      count++;
      while (a % i == 0) {
        a /= i;
      }
    }
  }
  return count;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k;
  cin >> n >> k;

  int ans = 0;
  for (int i = 2; i <= n; i++) {
    if (pf(i) >= k) {
      ans++;
    }
  }
  cout << ans << endl;
}

0