結果

問題 No.36 素数が嫌い!
ユーザー tentententen
提出日時 2022-07-28 17:14:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 1,465 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 74,596 KB
実行使用メモリ 51,084 KB
最終ジャッジ日時 2023-09-25 09:47:31
合計ジャッジ時間 5,585 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,300 KB
testcase_01 AC 50 ms
49,856 KB
testcase_02 AC 43 ms
49,288 KB
testcase_03 AC 43 ms
49,732 KB
testcase_04 AC 43 ms
49,280 KB
testcase_05 AC 45 ms
49,304 KB
testcase_06 AC 45 ms
49,284 KB
testcase_07 AC 44 ms
49,252 KB
testcase_08 AC 43 ms
49,300 KB
testcase_09 AC 43 ms
49,420 KB
testcase_10 AC 43 ms
49,584 KB
testcase_11 AC 85 ms
50,452 KB
testcase_12 AC 161 ms
50,856 KB
testcase_13 AC 160 ms
50,504 KB
testcase_14 AC 45 ms
49,396 KB
testcase_15 AC 43 ms
49,300 KB
testcase_16 AC 43 ms
49,328 KB
testcase_17 AC 42 ms
49,476 KB
testcase_18 AC 42 ms
49,304 KB
testcase_19 AC 42 ms
49,268 KB
testcase_20 AC 53 ms
51,084 KB
testcase_21 AC 45 ms
49,280 KB
testcase_22 AC 45 ms
49,396 KB
testcase_23 AC 43 ms
49,732 KB
testcase_24 AC 65 ms
50,752 KB
testcase_25 AC 42 ms
49,276 KB
testcase_26 AC 157 ms
50,668 KB
testcase_27 AC 147 ms
50,780 KB
testcase_28 AC 155 ms
50,768 KB
testcase_29 AC 156 ms
50,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        if (canUse(sc.nextLong())) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
    static boolean canUse(long x) {
        for (int i = 2; i <= Math.sqrt(x); i++) {
            if (x % i == 0) {
                if (!isPrime(i) || !isPrime(x / i)) {
                    return true;
                }
            }
        }
        return false;
    }
    static boolean isPrime(long x) {
        for (int i = 2; i <= Math.sqrt(x); i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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 String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0