結果

問題 No.36 素数が嫌い!
ユーザー YamaKasa
提出日時 2018-06-15 00:20:50
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 74,552 KB
実行使用メモリ 61,092 KB
最終ジャッジ日時 2024-06-30 14:38:06
合計ジャッジ時間 15,807 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 6 WA * 4 TLE * 2 -- * 14
権限があれば一括ダウンロードができます

ソースコード

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(isPrime(N)) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}

	}
	public static boolean isPrime(long n) {
	    if (n < 2) return false;
	    else if (n == 2) return true;
	    else if (n % 2 == 0) return false;

	    for (long i = 3; i < n; i += 2) {
	        if (n % i == 0) {
	            return false;
	        }
	    }

	    return true;
	}
}
0