結果

問題 No.106 素数が嫌い!2
ユーザー face4face4
提出日時 2018-05-20 17:25:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,053 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 75,404 KB
実行使用メモリ 11,236 KB
最終ジャッジ日時 2023-09-11 00:05:12
合計ジャッジ時間 2,116 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 30 ms
10,896 KB
testcase_02 AC 25 ms
10,956 KB
testcase_03 WA -
testcase_04 AC 25 ms
11,024 KB
testcase_05 AC 26 ms
10,948 KB
testcase_06 AC 30 ms
10,912 KB
testcase_07 AC 31 ms
10,980 KB
testcase_08 AC 26 ms
11,112 KB
testcase_09 AC 26 ms
10,956 KB
testcase_10 AC 27 ms
11,040 KB
testcase_11 AC 27 ms
10,892 KB
testcase_12 AC 31 ms
10,944 KB
testcase_13 WA -
testcase_14 AC 25 ms
10,904 KB
testcase_15 AC 25 ms
11,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    vector<int> factor(2e6+1, 0);
    vector<bool> nonprime(2e6+1, false);
    for(int i = 2; i < 2e6+1; i++){
        if(!nonprime[i]){
            nonprime[i] = true;
            for(int j = i+i; j < 2e6+1; j+=i){
                nonprime[j] = true;
                factor[j]++;
            }
        }
    }

    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for(int i = 2; i <= n; i++){
        if(factor[i] >= k)    cnt++;
    }

    cout << cnt << endl;
    return 0;
}

// 3560ms(!!)
// 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;
// }
0