結果

問題 No.36 素数が嫌い!
ユーザー shinshin
提出日時 2022-05-18 10:15:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 993 bytes
コンパイル時間 6,765 ms
コンパイル使用メモリ 75,040 KB
実行使用メモリ 51,220 KB
最終ジャッジ日時 2023-10-14 16:44:38
合計ジャッジ時間 9,608 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
49,392 KB
testcase_01 AC 45 ms
49,208 KB
testcase_02 AC 39 ms
49,124 KB
testcase_03 AC 38 ms
47,312 KB
testcase_04 AC 39 ms
49,056 KB
testcase_05 AC 41 ms
49,256 KB
testcase_06 AC 41 ms
49,244 KB
testcase_07 AC 40 ms
49,268 KB
testcase_08 AC 38 ms
49,132 KB
testcase_09 AC 40 ms
49,204 KB
testcase_10 AC 41 ms
51,220 KB
testcase_11 AC 69 ms
50,696 KB
testcase_12 AC 102 ms
50,848 KB
testcase_13 AC 99 ms
50,976 KB
testcase_14 AC 39 ms
49,280 KB
testcase_15 AC 39 ms
49,048 KB
testcase_16 AC 38 ms
49,404 KB
testcase_17 AC 39 ms
49,280 KB
testcase_18 AC 38 ms
49,140 KB
testcase_19 AC 51 ms
50,656 KB
testcase_20 AC 48 ms
49,284 KB
testcase_21 AC 58 ms
50,660 KB
testcase_22 AC 44 ms
49,400 KB
testcase_23 AC 41 ms
47,400 KB
testcase_24 AC 57 ms
50,892 KB
testcase_25 AC 60 ms
50,844 KB
testcase_26 AC 70 ms
50,700 KB
testcase_27 AC 47 ms
49,216 KB
testcase_28 AC 73 ms
50,932 KB
testcase_29 AC 45 ms
49,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class No36_2 {
	
	static int res = 0;

	public static void main(String[] args) throws IOException{
		//素数が嫌い!
		long N = Long.parseLong(readStr()[0]);
		
		while(N % 2 == 0) {
			res++;
			N /= 2;
		}

		long i = 3l;
		
		if(res == 2 && N > 1) {
			res++;
		}else if(res < 3){
			
			while(i <= N) {
				if(N % i == 0) {
					res++;
					N /= i;
					if(i < N) res++;
				}else {
					i += 2;
					if(i != N && i >= (long)Math.sqrt(N)) break;
				}
			}
		}
		
		System.out.println(res > 2 ? "YES" : "NO");

	}
	

	
	public static String[] readStr() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<>();

		do {
			list.add(br.readLine());
		}while(br.ready());

		br.close();

		String[] text = new String[list.size()];
		list.toArray(text);

		return text;

	}

}
0