結果

問題 No.106 素数が嫌い!2
ユーザー kuisiba
提出日時 2016-10-17 16:32:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 502 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 55,432 KB
実行使用メモリ 16,840 KB
最終ジャッジ日時 2024-11-22 13:20:47
合計ジャッジ時間 64,331 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

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