結果

問題 No.106 素数が嫌い!2
ユーザー むらためむらため
提出日時 2019-01-23 18:16:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 901 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 176,268 KB
実行使用メモリ 7,376 KB
最終ジャッジ日時 2023-10-14 09:27:48
合計ジャッジ時間 2,940 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 10 ms
5,492 KB
testcase_05 AC 18 ms
7,376 KB
testcase_06 AC 17 ms
7,376 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 8 ms
5,204 KB
testcase_12 AC 18 ms
7,220 KB
testcase_13 AC 1 ms
4,356 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include "bits/stdc++.h"

using namespace std;
// #define int long long
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define ALL(a) begin(a), end(a)
#define let const auto
int scan() {
  int result = 0;
  while (true) {
    auto k = getchar_unlocked();
    if (k < '0') break;
    result = 10 * result + k - '0';
  }
  return result;
}
int16_t F[20000010];
signed main() {
  let n = scan();
  let k = scan();
  if (k == 1) {
    printf("%d\n", n - 1);
    return 0;
  } else if (k >= 8) {
    printf("0\n");
    return 0;
  }
  int ans = 0;
  const int n1 = n + 1;
  FOR(i, 2, n / k + 1) {
    if (F[i] > 0) continue;
    for (int j = i; j < n1; j += i) {
      F[j]++;
      if (F[j] == k) ans++;
    }
  }
  printf("%d\n", ans);
}
0