結果

問題 No.106 素数が嫌い!2
ユーザー tenten
提出日時 2020-11-17 19:22:26
言語 Java
(openjdk 23)
結果
AC  
実行時間 164 ms / 5,000 ms
コード長 598 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 74,164 KB
実行使用メモリ 60,484 KB
最終ジャッジ日時 2024-07-23 08:25:22
合計ジャッジ時間 5,371 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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