結果

問題 No.36 素数が嫌い!
コンテスト
ユーザー YamaKasa
提出日時 2018-06-15 02:12:38
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 559 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,617 ms
コンパイル使用メモリ 82,420 KB
実行使用メモリ 43,520 KB
最終ジャッジ日時 2026-03-20 17:02:26
合計ジャッジ時間 4,650 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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