結果

問題 No.106 素数が嫌い!2
ユーザー GrayCoderGrayCoder
提出日時 2018-08-14 19:47:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 690 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 174,708 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:13:37
合計ジャッジ時間 37,550 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

vector<long> prime_factors(long n) {
  vector<long> ret;
  long i = 2;
  while (i * i <= n) {
    if (n % i)
      i += 1;
    else {
      n /= i;
      ret.push_back(i);
    }
  }
  if (n > 1) ret.push_back(n);
  return ret;
}

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long N; int K;
  cin >> N;
  cin >> K;
  long ans = 0;
  for (long i = 2; i <= N; i++) {
    vector<long> ret;
    ret = prime_factors(i);
    set<long> primes(ret.begin(), ret.end());
    if (primes.size() >= K) ans++;
  }
  cout << ans << endl;
  return 0;
}
0