結果

問題 No.106 素数が嫌い!2
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-08 02:48:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 3,817 ms / 5,000 ms
コード長 783 bytes
コンパイル時間 3,857 ms
コンパイル使用メモリ 71,520 KB
実行使用メモリ 56,160 KB
最終ジャッジ日時 2023-08-18 20:39:14
合計ジャッジ時間 24,025 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 380 ms
56,004 KB
testcase_01 AC 124 ms
55,816 KB
testcase_02 AC 125 ms
55,480 KB
testcase_03 AC 122 ms
55,972 KB
testcase_04 AC 655 ms
56,128 KB
testcase_05 AC 2,676 ms
56,000 KB
testcase_06 AC 3,817 ms
55,956 KB
testcase_07 AC 3,581 ms
55,812 KB
testcase_08 AC 161 ms
55,704 KB
testcase_09 AC 203 ms
56,160 KB
testcase_10 AC 3,585 ms
55,976 KB
testcase_11 AC 1,234 ms
53,808 KB
testcase_12 AC 2,712 ms
55,524 KB
testcase_13 AC 123 ms
55,812 KB
testcase_14 AC 122 ms
55,472 KB
testcase_15 AC 123 ms
55,592 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+=2){
                if(t%j==0){
                    p++;
                    if(p>=K){break;}
                    while(t%j==0){
                        t/=j;
                    }
                }
            }
            if(t!=1){p++;}
            if(p>=K){c++;}
        }
        System.out.println(c);
    }
}
0