結果

問題 No.106 素数が嫌い!2
ユーザー tentententen
提出日時 2020-11-17 19:22:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 598 bytes
コンパイル時間 1,876 ms
コンパイル使用メモリ 71,760 KB
実行使用メモリ 62,092 KB
最終ジャッジ日時 2023-09-30 14:22:34
合計ジャッジ時間 5,047 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
60,000 KB
testcase_01 AC 119 ms
56,004 KB
testcase_02 AC 120 ms
56,052 KB
testcase_03 AC 120 ms
56,216 KB
testcase_04 AC 142 ms
59,964 KB
testcase_05 AC 151 ms
60,128 KB
testcase_06 AC 151 ms
62,068 KB
testcase_07 AC 149 ms
62,048 KB
testcase_08 AC 129 ms
56,188 KB
testcase_09 AC 130 ms
55,464 KB
testcase_10 AC 153 ms
62,092 KB
testcase_11 AC 140 ms
58,432 KB
testcase_12 AC 153 ms
61,968 KB
testcase_13 AC 120 ms
56,512 KB
testcase_14 AC 119 ms
56,132 KB
testcase_15 AC 119 ms
55,432 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[] counts = new int[n + 1];
        for (int i = 2; i <= n; i++) {
            if (counts[i] == 0) {
                for (int j = 1; j * i <= n; j++) {
                    counts[j * i]++;
                }
            }
        }
        int ans = 0;
        for (int x : counts) {
            if (x >= k) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}
0