結果

問題 No.36 素数が嫌い!
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-15 02:22:33
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,485 bytes
コンパイル時間 1,986 ms
コンパイル使用メモリ 73,580 KB
実行使用メモリ 56,176 KB
最終ジャッジ日時 2023-09-17 20:22:26
合計ジャッジ時間 9,353 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 297 ms
55,800 KB
testcase_03 AC 296 ms
56,044 KB
testcase_04 AC 295 ms
55,988 KB
testcase_05 WA -
testcase_06 AC 294 ms
56,160 KB
testcase_07 AC 293 ms
56,120 KB
testcase_08 AC 295 ms
55,968 KB
testcase_09 AC 295 ms
55,612 KB
testcase_10 AC 295 ms
55,928 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 292 ms
55,604 KB
testcase_16 AC 295 ms
56,008 KB
testcase_17 AC 294 ms
55,456 KB
testcase_18 AC 296 ms
55,640 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int num = koko.nextInt();
        
        int counter = 0;                    
        int ptr = 0;                        
        int[] prime = new int[10000];  

        prime[ptr++] = 2;
        prime[ptr++] = 3;           

        for (int n = 5; n <= 100000; n += 2) {      
            int i;
            for (i = 1; i < ptr; i++) { 
                counter++;
                if (n % prime[i] == 0)      
                    break;                      
            }
            if (ptr == i)                       
                prime[ptr++] = n;              
        }
        int count=0;
        int mul=1;
        for(int j=0; j<ptr; j++){
            if(num<=prime[j]){
                break;
            }else if(num%prime[j]==0){
                count++;
                mul=mul*prime[j];
            }
        }
        if(count>2){
            System.out.println("YES");
        }else if(count==2){
            if(mul==num){
                System.out.println("NO");
            }else{
                System.out.println("YES");
            }
        }else if(count==1){
            if(mul*mul==num){
                System.out.println("NO");
            }else{
                System.out.println("YES");
            }
        }else if(count==0){
            System.out.println("NO");
        }
    }
}
0