結果
問題 |
No.106 素数が嫌い!2
|
ユーザー |
![]() |
提出日時 | 2020-07-29 11:10:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 5,000 ms |
コード長 | 671 bytes |
コンパイル時間 | 2,137 ms |
コンパイル使用メモリ | 192,924 KB |
最終ジャッジ日時 | 2025-01-12 07:30:46 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair<int,int> P; constexpr int m = 2000000; int cnt[m + 1]; bool is_prime[m + 1]; void init() { for (int i = 2; i <= m; i++) is_prime[i] = true; for (int i = 2; i <= m; i++) { if (!is_prime[i]) continue; cnt[i]++; for (int j = i + i; j <= m; j += i) { is_prime[j] = false; cnt[j]++; } } } int main() { init(); int n, k; cin >> n >> k; int res = 0; for (int i = 2; i <= n; i++) { if (cnt[i] >= k) res++; } cout << res << endl; return 0; }