結果

問題 No.106 素数が嫌い!2
ユーザー GrenacheGrenache
提出日時 2015-11-23 20:05:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 163 ms / 5,000 ms
コード長 610 bytes
コンパイル時間 3,333 ms
コンパイル使用メモリ 72,588 KB
実行使用メモリ 47,492 KB
最終ジャッジ日時 2023-10-11 18:23:04
合計ジャッジ時間 6,465 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
43,204 KB
testcase_01 AC 119 ms
39,448 KB
testcase_02 AC 118 ms
39,392 KB
testcase_03 AC 118 ms
39,596 KB
testcase_04 AC 146 ms
43,136 KB
testcase_05 AC 159 ms
47,064 KB
testcase_06 AC 158 ms
47,328 KB
testcase_07 AC 160 ms
47,492 KB
testcase_08 AC 129 ms
39,856 KB
testcase_09 AC 129 ms
39,776 KB
testcase_10 AC 161 ms
47,272 KB
testcase_11 AC 144 ms
42,452 KB
testcase_12 AC 163 ms
46,992 KB
testcase_13 AC 122 ms
39,356 KB
testcase_14 AC 119 ms
39,196 KB
testcase_15 AC 119 ms
39,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder106 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] cnt = new int[n + 1];
        for (int i = 2; i <= n; i++) {
        	if (cnt[i] == 0) {
        		for (int j = 1; i * j <= n; j++) {
        			cnt[i * j]++;
        		}
        	}
        }

        int ret = 0;
        for (int i = 2; i <= n; i++) {
        	if (cnt[i] >= k) {
        		ret++;
        	}
        }

        System.out.println(ret);

        sc.close();
    }
}
0