結果

問題 No.36 素数が嫌い!
ユーザー shinshin
提出日時 2022-05-18 08:44:29
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 953 bytes
コンパイル時間 6,841 ms
コンパイル使用メモリ 74,956 KB
実行使用メモリ 50,392 KB
最終ジャッジ日時 2023-10-14 14:43:11
合計ジャッジ時間 9,776 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
50,040 KB
testcase_01 AC 50 ms
50,228 KB
testcase_02 AC 43 ms
49,324 KB
testcase_03 WA -
testcase_04 AC 43 ms
49,456 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 47 ms
49,384 KB
testcase_08 AC 44 ms
49,232 KB
testcase_09 AC 43 ms
49,572 KB
testcase_10 AC 43 ms
49,644 KB
testcase_11 AC 85 ms
49,724 KB
testcase_12 AC 155 ms
49,764 KB
testcase_13 AC 155 ms
49,944 KB
testcase_14 AC 46 ms
49,532 KB
testcase_15 AC 44 ms
49,500 KB
testcase_16 AC 43 ms
49,832 KB
testcase_17 AC 44 ms
49,424 KB
testcase_18 AC 44 ms
49,440 KB
testcase_19 AC 56 ms
48,632 KB
testcase_20 AC 56 ms
50,392 KB
testcase_21 AC 66 ms
50,252 KB
testcase_22 AC 50 ms
49,960 KB
testcase_23 AC 47 ms
49,896 KB
testcase_24 AC 68 ms
50,228 KB
testcase_25 AC 71 ms
50,080 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.TreeSet;

public class No36 {
	
	static TreeSet<Integer> ts = new TreeSet<>();

	public static void main(String[] args) throws IOException{
		//素数が嫌い!
		long N = Long.parseLong(readStr()[0]);
		
		wari(N);
		
		System.out.println(ts.size() > 1 ? "YES" : "NO");

	}
	
	public static void wari(long a) {
		int sq = (int)Math.sqrt(a);
		for(int i = 2;i <= sq;i++) {
			if(a % i == 0) {
				ts.add(i);
				ts.add((int)(a / i));
				wari(a / i);
				break;
			}
		}
	}
	
	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