結果

問題 No.889 素数!
ユーザー yukiyuki
提出日時 2020-08-19 16:26:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,770 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 77,576 KB
実行使用メモリ 41,664 KB
最終ジャッジ日時 2024-04-20 09:30:06
合計ジャッジ時間 12,686 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,568 KB
testcase_01 AC 126 ms
41,664 KB
testcase_02 AC 134 ms
41,264 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 133 ms
41,328 KB
testcase_06 AC 134 ms
41,384 KB
testcase_07 AC 134 ms
40,956 KB
testcase_08 AC 132 ms
41,048 KB
testcase_09 WA -
testcase_10 AC 133 ms
41,056 KB
testcase_11 AC 132 ms
41,184 KB
testcase_12 AC 132 ms
41,268 KB
testcase_13 AC 129 ms
41,056 KB
testcase_14 AC 134 ms
41,440 KB
testcase_15 AC 133 ms
41,076 KB
testcase_16 AC 134 ms
41,240 KB
testcase_17 AC 140 ms
41,404 KB
testcase_18 AC 122 ms
40,228 KB
testcase_19 AC 134 ms
41,208 KB
testcase_20 AC 132 ms
41,448 KB
testcase_21 AC 135 ms
41,376 KB
testcase_22 AC 133 ms
41,280 KB
testcase_23 AC 132 ms
41,596 KB
testcase_24 AC 133 ms
41,048 KB
testcase_25 AC 131 ms
41,404 KB
testcase_26 AC 131 ms
41,276 KB
testcase_27 AC 131 ms
41,152 KB
testcase_28 AC 132 ms
41,196 KB
testcase_29 WA -
testcase_30 AC 133 ms
41,388 KB
testcase_31 AC 134 ms
41,052 KB
testcase_32 AC 122 ms
40,268 KB
testcase_33 AC 131 ms
41,472 KB
testcase_34 AC 119 ms
40,060 KB
testcase_35 AC 134 ms
41,160 KB
testcase_36 AC 140 ms
41,368 KB
testcase_37 AC 137 ms
41,504 KB
testcase_38 AC 133 ms
41,316 KB
testcase_39 AC 132 ms
41,092 KB
testcase_40 AC 134 ms
41,220 KB
testcase_41 AC 134 ms
41,012 KB
testcase_42 AC 134 ms
41,316 KB
testcase_43 AC 136 ms
41,252 KB
testcase_44 AC 137 ms
41,204 KB
testcase_45 AC 123 ms
40,072 KB
testcase_46 AC 135 ms
40,960 KB
testcase_47 AC 136 ms
40,932 KB
testcase_48 AC 138 ms
41,464 KB
testcase_49 AC 134 ms
41,408 KB
testcase_50 AC 123 ms
40,224 KB
testcase_51 AC 134 ms
41,000 KB
testcase_52 AC 130 ms
41,464 KB
testcase_53 AC 131 ms
41,224 KB
testcase_54 AC 136 ms
41,452 KB
testcase_55 AC 120 ms
40,076 KB
testcase_56 AC 131 ms
41,148 KB
testcase_57 AC 119 ms
41,288 KB
testcase_58 AC 116 ms
41,096 KB
testcase_59 AC 128 ms
41,424 KB
testcase_60 AC 134 ms
41,632 KB
testcase_61 AC 134 ms
41,216 KB
testcase_62 AC 134 ms
41,276 KB
testcase_63 AC 138 ms
41,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
		int N = in.nextInt();
		int a = (int)Math.sqrt(N);  // square number

        if(isPrime(N)){
            System.out.println("Sosu!");
        }else if(isSQnum(N, a)){
            System.out.println("Heihosu!");            
        }else if(isQubicNum(N)){
            System.out.println("Ripposu!");
        }else if(isPerfect(N)){
            System.out.println("Kanzensu!");
        }else{
            System.out.println(N);            
        }
        
   }
   
    static boolean isPrime(int N){
        if(N == 2)
            return true;
        else{
            // N(判定する数)までで、割り切れる数があれば、
            // それは素数ではない
            for(int i=2; i<N; i++){
                if(N % i == 0){
                    return false;
                }
            }
            return true;
        }        

    }
    
    static boolean isSQnum(int N, int a){
        if(N>=2 && a*a == N){
            return true;
        }
        return false;
    }
    
    static boolean isQubicNum(int N){
        if(Math.pow(N, 1.0 / 3) >= 2.0){
            double root = Math.pow(N, 1.0 / 3);
            if(root - Math.floor(root) == 0)
                return true;
            else
                return false;
        }
        return false;
    }
    
    static boolean isPerfect(int N){
        int sum = 0;
        for(int i=1; i<N/2; i++){
            if(N % 2 == 0){
                sum += N;
            }
        }
        if(sum == N) {
            return true;
        }
        return false;
        
    }

}
0