結果

問題 No.36 素数が嫌い!
ユーザー spaciaspacia
提出日時 2016-01-12 22:58:52
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 731 bytes
コンパイル時間 2,777 ms
コンパイル使用メモリ 74,412 KB
実行使用メモリ 59,140 KB
最終ジャッジ日時 2023-10-19 22:55:29
合計ジャッジ時間 10,421 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,544 KB
testcase_01 AC 60 ms
53,536 KB
testcase_02 AC 56 ms
53,532 KB
testcase_03 AC 55 ms
53,540 KB
testcase_04 AC 56 ms
53,528 KB
testcase_05 AC 57 ms
53,536 KB
testcase_06 AC 57 ms
53,536 KB
testcase_07 AC 55 ms
53,536 KB
testcase_08 AC 55 ms
53,540 KB
testcase_09 AC 56 ms
53,528 KB
testcase_10 AC 56 ms
52,440 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static boolean isPrime (long n) {
		if (n == 1 || (n != 2 && n % 2 == 0)) return false;
		for (int i = 3; i * i <= n; i += 2)
			if (n % i == 0) return false;
		return true;
	}
	
	public static boolean solve (long n) {
		if (n == 1) return false;
		for (int i = 2; i * i <= n; i++) {
			if (n % i != 0) continue;
			if (!isPrime(i) || !isPrime(n / i)) return true;
		}
		return false;
	}
	
	public static void main (String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		out(solve(Long.parseLong(br.readLine())) ? "YES" : "NO");
	}
}
0