結果

問題 No.889 素数!
ユーザー face4face4
提出日時 2019-09-16 16:30:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,312 bytes
コンパイル時間 3,841 ms
コンパイル使用メモリ 73,044 KB
実行使用メモリ 49,828 KB
最終ジャッジ日時 2023-09-21 07:59:15
合計ジャッジ時間 8,175 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,212 KB
testcase_01 AC 44 ms
49,284 KB
testcase_02 AC 43 ms
49,156 KB
testcase_03 AC 43 ms
49,280 KB
testcase_04 AC 43 ms
49,088 KB
testcase_05 AC 42 ms
49,276 KB
testcase_06 AC 42 ms
49,636 KB
testcase_07 AC 42 ms
49,148 KB
testcase_08 AC 43 ms
49,120 KB
testcase_09 AC 44 ms
49,624 KB
testcase_10 AC 43 ms
49,116 KB
testcase_11 AC 43 ms
49,208 KB
testcase_12 AC 42 ms
49,092 KB
testcase_13 AC 43 ms
49,088 KB
testcase_14 AC 44 ms
49,088 KB
testcase_15 AC 45 ms
49,640 KB
testcase_16 AC 43 ms
49,232 KB
testcase_17 AC 43 ms
49,608 KB
testcase_18 AC 43 ms
49,244 KB
testcase_19 AC 43 ms
49,144 KB
testcase_20 AC 43 ms
49,116 KB
testcase_21 AC 43 ms
49,096 KB
testcase_22 AC 43 ms
49,440 KB
testcase_23 AC 43 ms
49,280 KB
testcase_24 AC 43 ms
49,216 KB
testcase_25 AC 42 ms
49,200 KB
testcase_26 AC 43 ms
49,508 KB
testcase_27 AC 43 ms
49,380 KB
testcase_28 AC 44 ms
49,504 KB
testcase_29 AC 44 ms
49,200 KB
testcase_30 AC 43 ms
49,152 KB
testcase_31 AC 43 ms
49,132 KB
testcase_32 AC 43 ms
49,644 KB
testcase_33 AC 44 ms
47,580 KB
testcase_34 AC 44 ms
49,088 KB
testcase_35 AC 43 ms
49,220 KB
testcase_36 AC 43 ms
49,216 KB
testcase_37 AC 44 ms
49,048 KB
testcase_38 AC 45 ms
49,216 KB
testcase_39 AC 43 ms
49,608 KB
testcase_40 AC 43 ms
49,476 KB
testcase_41 AC 43 ms
49,828 KB
testcase_42 AC 43 ms
49,084 KB
testcase_43 AC 43 ms
47,732 KB
testcase_44 AC 42 ms
49,104 KB
testcase_45 AC 43 ms
47,696 KB
testcase_46 AC 43 ms
49,280 KB
testcase_47 AC 43 ms
49,460 KB
testcase_48 AC 43 ms
49,480 KB
testcase_49 AC 43 ms
49,616 KB
testcase_50 AC 43 ms
49,444 KB
testcase_51 AC 43 ms
49,212 KB
testcase_52 AC 43 ms
49,372 KB
testcase_53 AC 43 ms
49,272 KB
testcase_54 AC 43 ms
49,092 KB
testcase_55 AC 43 ms
49,140 KB
testcase_56 AC 43 ms
49,112 KB
testcase_57 AC 43 ms
49,152 KB
testcase_58 AC 43 ms
49,304 KB
testcase_59 AC 44 ms
49,088 KB
testcase_60 AC 43 ms
49,196 KB
testcase_61 AC 43 ms
49,280 KB
testcase_62 AC 43 ms
49,280 KB
testcase_63 AC 42 ms
49,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;

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) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int n = Integer.parseInt(line);
        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