結果

問題 No.106 素数が嫌い!2
ユーザー kou6839
提出日時 2014-12-20 20:16:55
言語 Java
(openjdk 23)
結果
AC  
実行時間 3,505 ms / 5,000 ms
コード長 547 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 74,928 KB
実行使用メモリ 41,696 KB
最終ジャッジ日時 2024-06-12 02:39:23
合計ジャッジ時間 25,784 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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