結果
問題 | No.106 素数が嫌い!2 |
ユーザー |
![]() |
提出日時 | 2014-12-18 23:36:39 |
言語 | C++11 (gcc 8.3.1) |
結果 |
AC
|
実行時間 | 42 ms / 5,000 ms |
コード長 | 526 Byte |
コンパイル時間 | 510 ms |
使用メモリ | 11,260 KB |
最終ジャッジ日時 | 2021-04-07 00:32:59 |
合計ジャッジ時間 | 1,931 ms |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
6,924 KB |
testcase_01 | AC | 1 ms
3,328 KB |
testcase_02 | AC | 2 ms
3,284 KB |
testcase_03 | AC | 1 ms
3,288 KB |
testcase_04 | AC | 17 ms
6,960 KB |
testcase_05 | AC | 41 ms
11,156 KB |
testcase_06 | AC | 41 ms
11,144 KB |
testcase_07 | AC | 41 ms
11,144 KB |
testcase_08 | AC | 3 ms
3,492 KB |
testcase_09 | AC | 3 ms
3,480 KB |
testcase_10 | AC | 42 ms
11,200 KB |
testcase_11 | AC | 15 ms
6,392 KB |
testcase_12 | AC | 39 ms
10,624 KB |
testcase_13 | AC | 1 ms
3,276 KB |
testcase_14 | AC | 1 ms
3,292 KB |
testcase_15 | AC | 1 ms
3,288 KB |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> using namespace std; int main(){ int N,K; cin >> N >> K; vector<int> v(N+1, 0); vector<bool> p(N+1, true); for(long long i=2; i<=N; ++i){ if(p[i] == false) continue; for(int j=i+i; j<=N; j+=i){ v[j]++; p[j] = false; } } long long ans = 0; for(int i=2; i<=N; i++){ ans += (v[i]+(p[i]?1:0))>=K?1:0; } cout << ans << endl; return 0; }