結果

問題 No.36 素数が嫌い!
ユーザー htensaihtensai
提出日時 2019-12-26 10:36:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 244 ms / 5,000 ms
コード長 952 bytes
コンパイル時間 3,169 ms
コンパイル使用メモリ 84,892 KB
実行使用メモリ 54,472 KB
最終ジャッジ日時 2024-04-14 07:41:25
合計ジャッジ時間 8,003 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
54,292 KB
testcase_01 AC 137 ms
54,308 KB
testcase_02 AC 116 ms
52,820 KB
testcase_03 AC 137 ms
54,260 KB
testcase_04 AC 132 ms
54,272 KB
testcase_05 AC 133 ms
53,992 KB
testcase_06 AC 135 ms
54,120 KB
testcase_07 AC 131 ms
54,124 KB
testcase_08 AC 133 ms
54,176 KB
testcase_09 AC 129 ms
54,472 KB
testcase_10 AC 131 ms
54,016 KB
testcase_11 AC 170 ms
53,856 KB
testcase_12 AC 244 ms
54,148 KB
testcase_13 AC 242 ms
54,156 KB
testcase_14 AC 131 ms
54,436 KB
testcase_15 AC 131 ms
53,888 KB
testcase_16 AC 129 ms
54,028 KB
testcase_17 AC 130 ms
54,036 KB
testcase_18 AC 132 ms
54,364 KB
testcase_19 AC 143 ms
53,856 KB
testcase_20 AC 141 ms
54,104 KB
testcase_21 AC 152 ms
54,252 KB
testcase_22 AC 141 ms
54,076 KB
testcase_23 AC 133 ms
54,260 KB
testcase_24 AC 154 ms
54,156 KB
testcase_25 AC 156 ms
54,168 KB
testcase_26 AC 175 ms
54,284 KB
testcase_27 AC 144 ms
54,396 KB
testcase_28 AC 182 ms
54,164 KB
testcase_29 AC 136 ms
54,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        HashMap<Long, Integer> map = new HashMap<>();
        for (long i = 2; i <= Math.sqrt(n); i++) {
            while (n % i == 0) {
                if (map.containsKey(i)) {
                    map.put(i, map.get(i) + 1);
                } else {
                    map.put(i, 1);
                }
                n /= i;
            }
        }
        if (n != 1) {
            if (map.containsKey(n)) {
                map.put(n, map.get(n) + 1);
            } else {
                map.put(n, 1);
            }
        }
        boolean flag = false;
        int sum = 0;
        for (int x : map.values()) {
            sum += x;
        }
        if (sum >= 3) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}
0