結果

問題 No.106 素数が嫌い!2
コンテスト
ユーザー Rumain831
提出日時 2026-08-12 17:28:50
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 15 ms / 5,000 ms
+ 794µs
コード長 324 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,236 ms
コンパイル使用メモリ 152,896 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2026-08-12 17:29:11
合計ジャッジ時間 3,276 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
using namespace std;

int cnt[2000001];
int main(void){
  int n, k; cin >> n >> k;
  for(int i=2; i<=n; i++){
    if(cnt[i]) continue;
    int now=i;
    while(now<=n){
      cnt[now]++;
      now+=i;
    }
  }
  int ans=0;
  for(int i=2; i<=n; i++) ans+=(cnt[i]>=k);
  cout << ans << endl;
  return 0; 
}
0