結果

問題 No.36 素数が嫌い!
ユーザー YamaKasaYamaKasa
提出日時 2018-06-15 02:37:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 228 ms / 5,000 ms
コード長 544 bytes
コンパイル時間 3,636 ms
コンパイル使用メモリ 72,632 KB
実行使用メモリ 57,908 KB
最終ジャッジ日時 2023-09-13 04:29:16
合計ジャッジ時間 9,108 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
55,876 KB
testcase_01 AC 205 ms
55,840 KB
testcase_02 AC 116 ms
56,056 KB
testcase_03 AC 118 ms
56,136 KB
testcase_04 AC 114 ms
53,648 KB
testcase_05 AC 128 ms
55,740 KB
testcase_06 AC 125 ms
55,772 KB
testcase_07 AC 117 ms
57,908 KB
testcase_08 AC 116 ms
55,916 KB
testcase_09 AC 117 ms
56,360 KB
testcase_10 AC 114 ms
55,724 KB
testcase_11 AC 155 ms
55,796 KB
testcase_12 AC 227 ms
55,832 KB
testcase_13 AC 228 ms
55,816 KB
testcase_14 AC 183 ms
55,584 KB
testcase_15 AC 117 ms
55,852 KB
testcase_16 AC 112 ms
55,628 KB
testcase_17 AC 115 ms
56,164 KB
testcase_18 AC 125 ms
55,932 KB
testcase_19 AC 167 ms
56,148 KB
testcase_20 AC 228 ms
56,016 KB
testcase_21 AC 204 ms
56,132 KB
testcase_22 AC 204 ms
56,408 KB
testcase_23 AC 169 ms
56,168 KB
testcase_24 AC 179 ms
56,412 KB
testcase_25 AC 176 ms
56,096 KB
testcase_26 AC 184 ms
56,228 KB
testcase_27 AC 214 ms
56,200 KB
testcase_28 AC 184 ms
55,900 KB
testcase_29 AC 221 ms
56,032 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) {
					cnt ++;
				}
			}
		}

		return cnt;
	}
}
0