結果

問題 No.106 素数が嫌い!2
ユーザー kuisibakuisiba
提出日時 2016-10-17 17:50:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 443 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 59,384 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-05-02 03:12:03
合計ジャッジ時間 1,445 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
7,004 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 12 ms
7,096 KB
testcase_05 AC 27 ms
10,880 KB
testcase_06 AC 24 ms
10,880 KB
testcase_07 AC 24 ms
11,008 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 29 ms
10,896 KB
testcase_11 AC 11 ms
6,656 KB
testcase_12 AC 29 ms
10,596 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>
#include <vector>

using namespace std;

int main() {

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

  int n, k;
  cin >> n >> k;
  vector<int> v(n+1);
  for (int i = 2; i <= n; i++) {
    if (v.at(i) == 0) {
      for (int j = i; j <= n; j += i) {
        v.at(j)++;
      }
    }
  }
  int ans{};
  for (int i = 2; i <= n; i++) {
    if (v.at(i) >= k) {
      ans++;
    }
  }
  cout << ans << endl;
}
0