結果

問題 No.36 素数が嫌い!
ユーザー YamaKasaYamaKasa
提出日時 2018-06-15 01:06:32
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 715 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 71,460 KB
実行使用メモリ 55,812 KB
最終ジャッジ日時 2023-09-13 04:26:42
合計ジャッジ時間 10,854 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,776 KB
testcase_01 AC 313 ms
55,452 KB
testcase_02 AC 127 ms
55,808 KB
testcase_03 AC 127 ms
55,740 KB
testcase_04 AC 124 ms
55,812 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		scan.close();
		if(isCheck(N)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
	public static boolean isCheck(long n) {
	    if (n <= 4) return false;

	    if(n % 4 == 0) return true;
	    for (long i = 5; i < n; i++) {
	        if (n % i == 0) {
	        	if(!isPrime(i)) {
	        		return true;
	        	}
	        }
	    }
	    return false;
	}
	public static boolean isPrime(long n) {
	    for (long i = 4; i < n; i ++) {
	        if (n % i == 0) {
	            return false;
	        }
	    }
	    return true;
	}
}
0