結果

問題 No.106 素数が嫌い!2
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-08 02:35:46
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 745 bytes
コンパイル時間 3,822 ms
コンパイル使用メモリ 70,856 KB
実行使用メモリ 59,736 KB
最終ジャッジ日時 2023-08-18 20:36:31
合計ジャッジ時間 24,520 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,417 ms
56,452 KB
testcase_01 AC 109 ms
55,668 KB
testcase_02 AC 111 ms
56,416 KB
testcase_03 AC 109 ms
56,500 KB
testcase_04 AC 2,079 ms
56,188 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 219 ms
56,456 KB
testcase_09 AC 226 ms
57,872 KB
testcase_10 TLE -
testcase_11 AC 1,805 ms
56,256 KB
testcase_12 TLE -
testcase_13 AC 113 ms
56,128 KB
testcase_14 AC 115 ms
55,824 KB
testcase_15 AC 116 ms
56,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int c=0;
        for(int i=2; i<=N; i++){
            int t=i;
            int p=0;
            while(t%2==0){
                t/=2;
                p=1;
            }
            int rt=(int)Math.sqrt(t);
            if(rt<3){rt=3;}
            for(int j=3; j<=rt; j++){
                if(t%j==0){
                    p++;
                    while(t%j==0){
                        t/=j;
                    }
                }
            }
            if(t!=1){p++;}
            if(p>=K){c++;}
        }
        System.out.println(c);
    }
}
0