結果

問題 No.36 素数が嫌い!
ユーザー YamaKasa
提出日時 2018-06-15 02:12:38
言語 Java
(openjdk 23)
結果
AC  
実行時間 231 ms / 5,000 ms
コード長 559 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 74,648 KB
実行使用メモリ 41,612 KB
最終ジャッジ日時 2024-06-30 14:40:33
合計ジャッジ時間 7,699 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

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

	}
	public static int numPrime(long n) {
		int cnt = 0;
		for(long i = 2; i <= (int)Math.sqrt(n); i++){
			if(n % i == 0) {
				cnt ++;
				if(n % (i * i) == 0 && n != i * i) {
					cnt ++;
				}
			}
		}

		return cnt;
	}
}
0