結果

問題 No.36 素数が嫌い!
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-16 05:42:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 188 ms / 5,000 ms
コード長 900 bytes
コンパイル時間 3,020 ms
コンパイル使用メモリ 71,544 KB
実行使用メモリ 56,148 KB
最終ジャッジ日時 2023-09-09 07:43:27
合計ジャッジ時間 7,694 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,448 KB
testcase_01 AC 158 ms
53,804 KB
testcase_02 AC 122 ms
55,540 KB
testcase_03 AC 124 ms
55,576 KB
testcase_04 AC 122 ms
56,056 KB
testcase_05 AC 126 ms
55,816 KB
testcase_06 AC 125 ms
56,120 KB
testcase_07 AC 125 ms
56,052 KB
testcase_08 AC 123 ms
56,148 KB
testcase_09 AC 122 ms
55,968 KB
testcase_10 AC 123 ms
55,728 KB
testcase_11 AC 146 ms
55,768 KB
testcase_12 AC 182 ms
55,864 KB
testcase_13 AC 185 ms
55,664 KB
testcase_14 AC 125 ms
55,964 KB
testcase_15 AC 125 ms
56,008 KB
testcase_16 AC 126 ms
55,896 KB
testcase_17 AC 124 ms
55,536 KB
testcase_18 AC 123 ms
55,740 KB
testcase_19 AC 144 ms
55,860 KB
testcase_20 AC 188 ms
55,596 KB
testcase_21 AC 158 ms
56,100 KB
testcase_22 AC 171 ms
56,000 KB
testcase_23 AC 154 ms
55,656 KB
testcase_24 AC 142 ms
55,700 KB
testcase_25 AC 157 ms
55,964 KB
testcase_26 AC 161 ms
55,788 KB
testcase_27 AC 175 ms
56,000 KB
testcase_28 AC 162 ms
55,652 KB
testcase_29 AC 182 ms
55,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int c=0;
        if(N%4==0){
            if(N==4){
                System.out.println("NO");
                return;
            }else{
                System.out.println("YES");
                return;
            }
        }else if(N%2==0){
            c=1;
            N/=2;
        }
        long M = (long)Math.sqrt(N);
        for(long i=3;i<=M; i+=2){
            while(N%i==0){
                c++;
                N/=i;
            }
            if(c>=3){
                System.out.println("YES");
                return;
            }
        }
        if(N>1){
            c++;
        }
        if(c>=3){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

0