結果

問題 No.106 素数が嫌い!2
ユーザー recososorecososo
提出日時 2020-02-13 11:42:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 707 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 164,960 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 14:01:03
合計ジャッジ時間 31,472 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 586 ms
6,944 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 35 ms
6,940 KB
testcase_09 AC 122 ms
6,940 KB
testcase_10 TLE -
testcase_11 AC 1,735 ms
6,940 KB
testcase_12 AC 3,040 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin >> n >> k;
    int ans=0;
    vector<bool> b(n+1);
    for(int i=2;i<=n;i++){
        if(b[i]){
            ans++;
            continue;
        }
        int num=i;
        int cnt=0;
        for(int j=2;j*j<=i;j++){
            bool f=false;
            while(num%j==0){
                num/=j;
                f=true;
            }
            if(f){
                cnt++;
            }
        }
        if(num!=1){
            cnt++;
        }
        if(cnt>=k){
            ans++;
            b[i]=true;
            for(int j=2;j*i<=n;j++){
                b[i*j]=true;
            }
        }
    }
    cout << ans << endl;
}
0