結果

問題 No.106 素数が嫌い!2
ユーザー kou6839kou6839
提出日時 2014-12-20 20:57:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 549 bytes
コンパイル時間 2,376 ms
コンパイル使用メモリ 71,096 KB
実行使用メモリ 62,188 KB
最終ジャッジ日時 2023-09-02 20:16:49
合計ジャッジ時間 5,666 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 123 ms
57,648 KB
testcase_02 AC 125 ms
55,708 KB
testcase_03 WA -
testcase_04 AC 145 ms
60,108 KB
testcase_05 AC 158 ms
61,908 KB
testcase_06 AC 158 ms
62,092 KB
testcase_07 AC 157 ms
61,968 KB
testcase_08 AC 134 ms
55,748 KB
testcase_09 AC 135 ms
55,968 KB
testcase_10 AC 160 ms
62,068 KB
testcase_11 AC 145 ms
58,092 KB
testcase_12 AC 154 ms
62,188 KB
testcase_13 WA -
testcase_14 AC 123 ms
55,684 KB
testcase_15 AC 122 ms
55,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;

class Main{
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] sosuu = new int[n+1];
        for(int i=2;i<=n;i++){
        	if(sosuu[i]==0){
        		int x = i*2;
        		while(x<=n){
        			sosuu[x]++;
        			x+=i;
        		}
        	}
        }
        int ans=0;
        for(int i=2;i<=n;i++){
        	if(sosuu[i]>=k) ans++;
        }
        System.out.println(ans);
    }
}
0