結果

問題 No.106 素数が嫌い!2
ユーザー rf141rf141
提出日時 2015-08-13 08:12:09
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 564 bytes
コンパイル時間 4,014 ms
コンパイル使用メモリ 71,104 KB
実行使用メモリ 60,648 KB
最終ジャッジ日時 2023-09-25 11:23:53
合計ジャッジ時間 16,682 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class HatePrenum{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int count = 0,calc = 0;
		boolean flag = true;
		for(int I = 2; I <= N; I++){
			while(I%2==0){
				I/=2;
				calc++;
				if(calc >= K){
					flag = false;
					break;
				}
			}

			if(flag){
				for(int i = 3; i*i<=N; i+=2){
					while(I%i==0){
						I/=i;
						calc++;
						if(calc>=K){
							flag = false;
							break;
						}
					}
				}
			}

			if(flag)count++;
		}
	}
}
0