結果

問題 No.106 素数が嫌い!2
ユーザー cympfhcympfh
提出日時 2015-01-16 15:43:33
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,761 bytes
コンパイル時間 1,671 ms
コンパイル使用メモリ 144,236 KB
実行使用メモリ 9,784 KB
最終ジャッジ日時 2023-09-04 13:35:41
合計ジャッジ時間 14,328 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);
typedef pair<Real, Real> P; // Point
typedef pair<P, P> L; // segment or line

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

int main(){

  auto ps = PrimeSieve(2e6+10);
  int n, k; cin >> n >> k;

  int ans = 0;
  range (m, 2, n + 1) {
    int cx = 0;
    int x = m;
    int idx = 0;
    while (x > 1) {
      while (!ps[idx]) ++idx;
      bool bl = false;
      while (x % idx == 0) {
        x /= idx;
        bl = true;
      }
      if (bl) ++cx;
      ++idx;
    }
    if (cx >= k) ++ans;
  }
  cout << ans << endl;

  return 0;
}

0