結果

問題 No.36 素数が嫌い!
ユーザー tentententen
提出日時 2023-02-14 13:57:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 5,000 ms
コード長 1,798 bytes
コンパイル時間 3,248 ms
コンパイル使用メモリ 87,980 KB
実行使用メモリ 51,000 KB
最終ジャッジ日時 2023-09-24 03:31:27
合計ジャッジ時間 6,576 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
50,716 KB
testcase_01 AC 48 ms
50,652 KB
testcase_02 AC 39 ms
49,244 KB
testcase_03 AC 37 ms
49,280 KB
testcase_04 AC 37 ms
50,024 KB
testcase_05 AC 37 ms
49,508 KB
testcase_06 AC 41 ms
49,332 KB
testcase_07 AC 44 ms
49,332 KB
testcase_08 AC 41 ms
49,440 KB
testcase_09 AC 37 ms
49,456 KB
testcase_10 AC 40 ms
49,352 KB
testcase_11 AC 78 ms
50,708 KB
testcase_12 AC 139 ms
50,704 KB
testcase_13 AC 145 ms
50,844 KB
testcase_14 AC 40 ms
49,676 KB
testcase_15 AC 37 ms
49,836 KB
testcase_16 AC 37 ms
49,280 KB
testcase_17 AC 37 ms
49,240 KB
testcase_18 AC 37 ms
49,348 KB
testcase_19 AC 46 ms
50,796 KB
testcase_20 AC 49 ms
51,000 KB
testcase_21 AC 62 ms
50,924 KB
testcase_22 AC 45 ms
49,240 KB
testcase_23 AC 44 ms
49,240 KB
testcase_24 AC 59 ms
50,812 KB
testcase_25 AC 65 ms
50,852 KB
testcase_26 AC 81 ms
50,860 KB
testcase_27 AC 46 ms
49,504 KB
testcase_28 AC 80 ms
50,748 KB
testcase_29 AC 40 ms
49,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long n = sc.nextLong();
        int ans = 0;
        for (int i = 2; i <= Math.sqrt(n); i++) {
            while (n % i == 0) {
                ans++;
                n /= i;
            }
        }
        if (n > 1) {
            ans++;
        }
        if (ans > 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0