結果

問題 No.106 素数が嫌い!2
ユーザー むらためむらため
提出日時 2019-01-23 18:12:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 2,154 ms
コンパイル使用メモリ 176,332 KB
実行使用メモリ 11,368 KB
最終ジャッジ日時 2023-10-14 09:26:58
合計ジャッジ時間 2,990 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 27 ms
11,368 KB
testcase_06 AC 27 ms
11,312 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 11 ms
6,900 KB
testcase_12 AC 26 ms
11,184 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 1 ms
4,348 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;
}
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) {
    if (F[i] > 0) continue;
    for (int j = i; j < n; j += i) {
      F[j]++;
      if (F[j] == k) ans++;
    }
  }
  printf("%d\n", ans);
}
0