結果

問題 No.106 素数が嫌い!2
ユーザー むらためむらため
提出日時 2019-01-23 18:14:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 881 bytes
コンパイル時間 2,375 ms
コンパイル使用メモリ 175,136 KB
実行使用メモリ 11,148 KB
最終ジャッジ日時 2023-10-14 09:27:02
合計ジャッジ時間 3,379 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 15 ms
7,336 KB
testcase_05 AC 31 ms
11,104 KB
testcase_06 AC 30 ms
11,148 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 AC 1 ms
4,356 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 12 ms
6,872 KB
testcase_12 AC 30 ms
10,996 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 1 ms
4,356 KB
testcase_15 AC 2 ms
4,352 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;
}
int 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;
  FOR(i, 2, n / k + 1) {
    if (F[i] > 0) continue;
    for (int j = i; j < n + 1; j += i) {
      F[j]++;
      if (F[j] == k) ans++;
    }
  }
  printf("%d\n", ans);
}
0