結果

問題 No.106 素数が嫌い!2
ユーザー imulanimulan
提出日時 2016-02-04 23:14:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 161,992 KB
実行使用メモリ 5,920 KB
最終ジャッジ日時 2023-10-21 19:14:39
合計ジャッジ時間 31,672 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 20 ms
5,920 KB
testcase_02 AC 20 ms
5,920 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 WA -
testcase_09 AC 129 ms
5,920 KB
testcase_10 TLE -
testcase_11 AC 1,693 ms
5,920 KB
testcase_12 TLE -
testcase_13 AC 21 ms
5,920 KB
testcase_14 AC 20 ms
5,920 KB
testcase_15 AC 20 ms
5,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

const int N=2000000;

int main(int argc, char const *argv[]) {
  bool prime[N+1];
  rep(i,N+1) prime[i]=true;
  prime[0]=prime[1]=false;
  for(int i=2; i<=N; ++i){
    if(prime[i])
      for(int j=2; i*j<=N; ++j) prime[i*j]=false;
  }

  vector<int> p;
  rep(i,N+1) if(prime[i]) p.pb(i);

  int n,k;
  cin >>n >>k;

  int ans=0;
  for(int i=2; i<=n; ++i){
    int ct=0;
    int t=i;

    rep(j,p.size()){
      if(j*j>i) break;
      if(i%p[j]==0) ++ct;
    }

    if(ct>=k) ++ans;
  }

  std::cout << ans << std::endl;
  return 0;
}
0