結果

問題 No.106 素数が嫌い!2
ユーザー kou6839kou6839
提出日時 2014-12-20 20:16:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 4,199 ms / 5,000 ms
コード長 547 bytes
コンパイル時間 3,516 ms
コンパイル使用メモリ 71,900 KB
実行使用メモリ 58,052 KB
最終ジャッジ日時 2023-09-02 20:16:42
合計ジャッジ時間 13,982 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,631 ms
55,776 KB
testcase_01 AC 126 ms
39,220 KB
testcase_02 AC 125 ms
55,712 KB
testcase_03 AC 124 ms
56,020 KB
testcase_04 AC 1,626 ms
56,240 KB
testcase_05 AC 4,199 ms
55,564 KB
testcase_06 AC 4,103 ms
56,236 KB
testcase_07 AC 4,098 ms
55,896 KB
testcase_08 AC 224 ms
58,052 KB
testcase_09 AC 235 ms
56,240 KB
testcase_10 AC 4,096 ms
55,668 KB
testcase_11 AC 1,384 ms
54,140 KB
testcase_12 AC 3,871 ms
56,332 KB
testcase_13 AC 127 ms
56,136 KB
testcase_14 AC 126 ms
55,860 KB
testcase_15 AC 123 ms
56,108 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 ans=0;
        for(int i=2;i<=n;i++){
        	int num=i;
        	int temp=0;
        	for(int j=2;j*j<=num;j++){
        		if(num%j==0) temp++;
        		while(num%j==0){
        			num/=j;
        		}
        	}
        	if(num>1) temp++;
        	if(temp>=k) ans++;
        	
        }
        System.out.println(ans);
    }
}
0