結果

問題 No.889 素数!
ユーザー face4face4
提出日時 2019-09-16 16:28:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 1,217 bytes
コンパイル時間 4,643 ms
コンパイル使用メモリ 78,208 KB
実行使用メモリ 56,720 KB
最終ジャッジ日時 2023-09-21 07:58:59
合計ジャッジ時間 13,855 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,948 KB
testcase_01 AC 124 ms
54,164 KB
testcase_02 AC 123 ms
53,732 KB
testcase_03 AC 124 ms
55,792 KB
testcase_04 AC 122 ms
56,080 KB
testcase_05 AC 123 ms
55,504 KB
testcase_06 AC 123 ms
55,948 KB
testcase_07 AC 123 ms
56,092 KB
testcase_08 AC 124 ms
55,696 KB
testcase_09 AC 127 ms
55,720 KB
testcase_10 AC 120 ms
55,932 KB
testcase_11 AC 120 ms
55,660 KB
testcase_12 AC 121 ms
55,944 KB
testcase_13 AC 122 ms
55,888 KB
testcase_14 AC 122 ms
55,816 KB
testcase_15 AC 120 ms
55,672 KB
testcase_16 AC 121 ms
55,444 KB
testcase_17 AC 120 ms
55,500 KB
testcase_18 AC 120 ms
55,760 KB
testcase_19 AC 121 ms
55,496 KB
testcase_20 AC 121 ms
56,056 KB
testcase_21 AC 122 ms
55,828 KB
testcase_22 AC 122 ms
55,772 KB
testcase_23 AC 122 ms
56,024 KB
testcase_24 AC 124 ms
55,452 KB
testcase_25 AC 123 ms
56,004 KB
testcase_26 AC 123 ms
55,688 KB
testcase_27 AC 121 ms
55,744 KB
testcase_28 AC 122 ms
55,844 KB
testcase_29 AC 122 ms
55,804 KB
testcase_30 AC 122 ms
55,980 KB
testcase_31 AC 120 ms
55,976 KB
testcase_32 AC 121 ms
55,944 KB
testcase_33 AC 121 ms
55,724 KB
testcase_34 AC 121 ms
55,964 KB
testcase_35 AC 123 ms
56,220 KB
testcase_36 AC 122 ms
56,288 KB
testcase_37 AC 121 ms
56,028 KB
testcase_38 AC 118 ms
55,520 KB
testcase_39 AC 123 ms
56,056 KB
testcase_40 AC 122 ms
55,764 KB
testcase_41 AC 120 ms
55,536 KB
testcase_42 AC 122 ms
55,692 KB
testcase_43 AC 121 ms
55,868 KB
testcase_44 AC 123 ms
55,724 KB
testcase_45 AC 123 ms
55,836 KB
testcase_46 AC 121 ms
55,448 KB
testcase_47 AC 122 ms
55,648 KB
testcase_48 AC 120 ms
55,728 KB
testcase_49 AC 121 ms
55,824 KB
testcase_50 AC 120 ms
55,484 KB
testcase_51 AC 121 ms
56,172 KB
testcase_52 AC 120 ms
55,720 KB
testcase_53 AC 122 ms
56,024 KB
testcase_54 AC 123 ms
56,384 KB
testcase_55 AC 123 ms
55,744 KB
testcase_56 AC 123 ms
56,004 KB
testcase_57 AC 121 ms
55,816 KB
testcase_58 AC 122 ms
55,848 KB
testcase_59 AC 124 ms
55,948 KB
testcase_60 AC 122 ms
56,156 KB
testcase_61 AC 123 ms
56,720 KB
testcase_62 AC 123 ms
53,656 KB
testcase_63 AC 121 ms
55,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
    static boolean isPrime(int x){
        if(x < 2)   return false;
        for(int i = 2; i < x; i++){
            if(x % i == 0)  return false;
        }
        return true;
    }

    static boolean isSquare(int x){
        for(int i = 1; i*i <= x; i++){
            if(i*i == x)    return true;
        }
        return false;
    }

    static boolean isCubic(int x){
        for(int i = 1; i*i*i <= x; i++){
            if(i*i*i == x)  return true;
        }
        return false;
    }

    static boolean isPerfect(int x){
        int sum = 0;
        for(int i = 1; i <= x; i++){
            if(x%i == 0)    sum += i;
        }
        return (sum == x+x);
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ans = "";
        if(n < 2)               ans = String.valueOf(n);
        else if(isPrime(n))     ans = "Sosu!";
        else if(isSquare(n))    ans = "Heihosu!";
        else if(isCubic(n))     ans = "Ripposu!";
        else if(isPerfect(n))   ans = "Kanzensu!";
        else                    ans = String.valueOf(n);
        System.out.println(ans);
    }
}
0