結果

問題 No.36 素数が嫌い!
ユーザー YamaKasaYamaKasa
提出日時 2018-06-15 02:12:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 234 ms / 5,000 ms
コード長 559 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 71,976 KB
実行使用メモリ 56,256 KB
最終ジャッジ日時 2023-09-13 04:29:06
合計ジャッジ時間 8,408 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
55,916 KB
testcase_01 AC 211 ms
55,732 KB
testcase_02 AC 124 ms
55,960 KB
testcase_03 AC 124 ms
56,012 KB
testcase_04 AC 124 ms
55,932 KB
testcase_05 AC 125 ms
56,072 KB
testcase_06 AC 125 ms
55,872 KB
testcase_07 AC 124 ms
55,924 KB
testcase_08 AC 122 ms
55,960 KB
testcase_09 AC 124 ms
55,928 KB
testcase_10 AC 124 ms
56,048 KB
testcase_11 AC 163 ms
56,016 KB
testcase_12 AC 234 ms
55,644 KB
testcase_13 AC 233 ms
55,732 KB
testcase_14 AC 193 ms
56,152 KB
testcase_15 AC 125 ms
55,684 KB
testcase_16 AC 127 ms
55,996 KB
testcase_17 AC 122 ms
56,032 KB
testcase_18 AC 123 ms
55,692 KB
testcase_19 AC 169 ms
55,860 KB
testcase_20 AC 234 ms
55,932 KB
testcase_21 AC 208 ms
56,188 KB
testcase_22 AC 209 ms
55,536 KB
testcase_23 AC 175 ms
55,928 KB
testcase_24 AC 184 ms
56,164 KB
testcase_25 AC 182 ms
55,916 KB
testcase_26 AC 193 ms
56,236 KB
testcase_27 AC 220 ms
55,956 KB
testcase_28 AC 192 ms
56,256 KB
testcase_29 AC 231 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

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