結果

問題 No.36 素数が嫌い!
ユーザー GrenacheGrenache
提出日時 2015-11-03 15:51:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 256 ms / 5,000 ms
コード長 896 bytes
コンパイル時間 3,806 ms
コンパイル使用メモリ 75,232 KB
実行使用メモリ 56,496 KB
最終ジャッジ日時 2023-09-09 07:24:41
合計ジャッジ時間 10,395 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 182 ms
55,960 KB
testcase_01 AC 233 ms
56,496 KB
testcase_02 AC 125 ms
55,736 KB
testcase_03 AC 126 ms
54,160 KB
testcase_04 AC 124 ms
56,032 KB
testcase_05 AC 125 ms
56,172 KB
testcase_06 AC 128 ms
56,028 KB
testcase_07 AC 125 ms
56,060 KB
testcase_08 AC 126 ms
55,880 KB
testcase_09 AC 127 ms
56,056 KB
testcase_10 AC 125 ms
56,208 KB
testcase_11 AC 167 ms
55,876 KB
testcase_12 AC 241 ms
56,052 KB
testcase_13 AC 238 ms
56,092 KB
testcase_14 AC 202 ms
53,996 KB
testcase_15 AC 126 ms
55,688 KB
testcase_16 AC 126 ms
56,104 KB
testcase_17 AC 125 ms
56,380 KB
testcase_18 AC 125 ms
55,560 KB
testcase_19 AC 174 ms
56,028 KB
testcase_20 AC 256 ms
56,192 KB
testcase_21 AC 215 ms
53,880 KB
testcase_22 AC 218 ms
55,736 KB
testcase_23 AC 183 ms
55,632 KB
testcase_24 AC 206 ms
56,360 KB
testcase_25 AC 191 ms
55,840 KB
testcase_26 AC 200 ms
55,712 KB
testcase_27 AC 227 ms
55,588 KB
testcase_28 AC 198 ms
56,156 KB
testcase_29 AC 239 ms
55,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main_yukicoder36 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

		Map<Long, Integer> hm = new HashMap<Long, Integer>();
		long tmp = n;
		for (long j = 2; j * j <= tmp; j++) {
			while (n % j == 0) {
				if (hm.containsKey(j)) {
					hm.put(j, hm.get(j) + 1);
				} else {
					hm.put(j, 1);
				}
				n /= j;
			}
		}
		if (n != 1) {
			if (hm.containsKey(n)) {
				hm.put(n, hm.get(n) + 1);
			} else {
				hm.put(n, 1);
			}
		}

		int max = 0;
		for (int e : hm.values()) {
			max = Math.max(max, e);
		}

		if (hm.size() == 1 && max == 2) {
			System.out.println("NO");
		} else if (max > 1 || hm.size() > 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
        
        sc.close();
    }
}
0