結果

問題 No.106 素数が嫌い!2
ユーザー kou6839kou6839
提出日時 2014-12-20 21:00:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 618 bytes
コンパイル時間 3,781 ms
コンパイル使用メモリ 70,536 KB
実行使用メモリ 62,556 KB
最終ジャッジ日時 2023-09-02 20:18:12
合計ジャッジ時間 5,834 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,428 KB
testcase_01 AC 124 ms
55,484 KB
testcase_02 AC 124 ms
55,724 KB
testcase_03 AC 125 ms
55,924 KB
testcase_04 AC 145 ms
59,792 KB
testcase_05 AC 157 ms
62,000 KB
testcase_06 AC 159 ms
62,004 KB
testcase_07 AC 159 ms
61,928 KB
testcase_08 AC 134 ms
55,716 KB
testcase_09 AC 134 ms
55,828 KB
testcase_10 AC 158 ms
62,556 KB
testcase_11 AC 145 ms
57,712 KB
testcase_12 AC 156 ms
61,864 KB
testcase_13 AC 123 ms
55,564 KB
testcase_14 AC 124 ms
55,624 KB
testcase_15 AC 124 ms
55,368 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();
        if(k==1){
        	System.out.println(n-1);return;
        }
        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