結果

問題 No.36 素数が嫌い!
ユーザー Grenache
提出日時 2015-11-03 15:46:13
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 824 bytes
コンパイル時間 4,071 ms
コンパイル使用メモリ 77,800 KB
実行使用メモリ 56,116 KB
最終ジャッジ日時 2024-09-13 12:08:53
合計ジャッジ時間 10,361 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 9
権限があれば一括ダウンロードができます

ソースコード

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 (max > 1 || hm.size() > 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
        
        sc.close();
    }
}
0