結果
| 問題 |
No.106 素数が嫌い!2
|
| コンテスト | |
| ユーザー |
latte0119
|
| 提出日時 | 2015-05-04 13:40:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 5,000 ms |
| コード長 | 480 bytes |
| コンパイル時間 | 468 ms |
| コンパイル使用メモリ | 59,432 KB |
| 実行使用メモリ | 13,184 KB |
| 最終ジャッジ日時 | 2024-07-05 18:53:14 |
| 合計ジャッジ時間 | 1,943 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int cnt[2000001];
bool f[2000001];
int main(){
fill_n(f, 2000001, true);
f[0] = f[1] = false;
for (int i = 2; i <= 2000000; i++){
if (!f[i])continue;
cnt[i]++;
for (int j = i + i; j <= 2000000; j += i){
cnt[j]++;
f[j] = false;
}
}
int N, K;
cin >> N >> K;
int ans = 0;
for (int i = 2; i <= N; i++){
if (cnt[i] >= K)ans++;
}
cout << ans << endl;
return 0;
}
latte0119