結果
問題 |
No.106 素数が嫌い!2
|
ユーザー |
|
提出日時 | 2025-07-03 16:18:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 457 ms / 5,000 ms |
コード長 | 777 bytes |
コンパイル時間 | 2,021 ms |
コンパイル使用メモリ | 199,052 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-07-03 16:18:55 |
合計ジャッジ時間 | 5,789 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int Need = 2000000; vector<int> allp; vector<bool> prime(Need+1,true); prime.at(0) = false; prime.at(1) = false; for(int i=2; i<=Need; i++){ if(!prime.at(i)) continue; allp.push_back(i); for(long long k=((long long)i)*i; k<=Need; k+=i) prime.at(k) = false; } int N,K; cin >> N >> K; int answer = 0; for(int i=2; i<=N; i++){ int v = i,now = 0; for(auto p : allp){ if(p*p > v) break; if(v%p) continue; now++; while(v%p == 0) v /= p; } if(v != 1) now++; answer += now>=K; } cout << answer << endl; }