結果
問題 | No.106 素数が嫌い!2 |
ユーザー | face4 |
提出日時 | 2018-05-20 17:13:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,175 ms / 5,000 ms |
コード長 | 463 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 67,776 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-11 00:05:09 |
合計ジャッジ時間 | 15,661 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 831 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 831 ms
4,376 KB |
testcase_05 | AC | 2,173 ms
4,380 KB |
testcase_06 | AC | 2,175 ms
4,380 KB |
testcase_07 | AC | 2,174 ms
4,376 KB |
testcase_08 | AC | 55 ms
4,380 KB |
testcase_09 | AC | 59 ms
4,376 KB |
testcase_10 | AC | 2,174 ms
4,376 KB |
testcase_11 | AC | 698 ms
4,376 KB |
testcase_12 | AC | 2,055 ms
4,376 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,376 KB |
ソースコード
#include<iostream> #include<cmath> using namespace std; int count(int n){ int cnt = 0; for(int i = 2; i <= sqrt(n); i++){ if(n%i == 0){ cnt+=1; n/=i; while(n%i == 0) n/=i; } } if(n != 1) cnt++; return cnt; } int main(){ int n, k; cin >> n >> k; int ans = n-1; for(int i = 2; i <= n; i++){ if(count(i) < k) ans--; } cout << ans << endl; return 0; }