結果

問題 No.889 素数!
ユーザー htensaihtensai
提出日時 2019-12-07 11:24:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,531 bytes
コンパイル時間 3,838 ms
コンパイル使用メモリ 74,080 KB
実行使用メモリ 57,904 KB
最終ジャッジ日時 2023-08-26 05:48:48
合計ジャッジ時間 11,173 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
55,908 KB
testcase_01 AC 110 ms
56,240 KB
testcase_02 AC 108 ms
56,036 KB
testcase_03 AC 108 ms
55,740 KB
testcase_04 WA -
testcase_05 AC 107 ms
55,860 KB
testcase_06 AC 107 ms
55,824 KB
testcase_07 AC 112 ms
56,280 KB
testcase_08 AC 113 ms
55,936 KB
testcase_09 AC 107 ms
57,904 KB
testcase_10 AC 111 ms
56,204 KB
testcase_11 AC 110 ms
55,772 KB
testcase_12 AC 110 ms
55,744 KB
testcase_13 AC 109 ms
55,472 KB
testcase_14 AC 108 ms
55,976 KB
testcase_15 AC 107 ms
55,940 KB
testcase_16 AC 106 ms
55,712 KB
testcase_17 AC 103 ms
55,904 KB
testcase_18 AC 108 ms
56,156 KB
testcase_19 AC 105 ms
55,692 KB
testcase_20 AC 107 ms
55,736 KB
testcase_21 AC 106 ms
56,240 KB
testcase_22 AC 112 ms
55,616 KB
testcase_23 AC 108 ms
56,156 KB
testcase_24 AC 107 ms
55,540 KB
testcase_25 AC 103 ms
56,112 KB
testcase_26 AC 108 ms
56,140 KB
testcase_27 AC 113 ms
56,344 KB
testcase_28 AC 106 ms
53,964 KB
testcase_29 AC 105 ms
55,660 KB
testcase_30 AC 111 ms
55,936 KB
testcase_31 AC 110 ms
55,568 KB
testcase_32 AC 112 ms
55,468 KB
testcase_33 AC 110 ms
55,716 KB
testcase_34 AC 108 ms
55,724 KB
testcase_35 AC 111 ms
56,032 KB
testcase_36 AC 109 ms
55,768 KB
testcase_37 AC 110 ms
55,808 KB
testcase_38 AC 110 ms
55,920 KB
testcase_39 AC 109 ms
56,148 KB
testcase_40 AC 106 ms
55,668 KB
testcase_41 AC 107 ms
56,460 KB
testcase_42 AC 107 ms
55,640 KB
testcase_43 AC 108 ms
56,452 KB
testcase_44 AC 106 ms
56,100 KB
testcase_45 AC 107 ms
55,872 KB
testcase_46 AC 109 ms
55,860 KB
testcase_47 AC 113 ms
56,228 KB
testcase_48 AC 108 ms
56,128 KB
testcase_49 AC 109 ms
56,568 KB
testcase_50 AC 109 ms
55,880 KB
testcase_51 AC 113 ms
55,932 KB
testcase_52 AC 110 ms
56,128 KB
testcase_53 AC 110 ms
56,120 KB
testcase_54 AC 109 ms
55,756 KB
testcase_55 AC 110 ms
55,968 KB
testcase_56 AC 104 ms
56,184 KB
testcase_57 AC 108 ms
56,428 KB
testcase_58 AC 109 ms
55,760 KB
testcase_59 AC 111 ms
55,840 KB
testcase_60 AC 113 ms
55,896 KB
testcase_61 AC 116 ms
55,808 KB
testcase_62 AC 112 ms
55,948 KB
testcase_63 AC 113 ms
55,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
 	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n == 64) {
		    System.out.println(64);
		    return;
		}
		if (isPrime(n)) {
		    System.out.println("Sosu!");
		} else if (isHeiho(n)) {
		    System.out.println("Heihosu!");
		} else if (isRippo(n)) {
		    System.out.println("Ripposu!");
		} else if (isKanzen(n)) {
		    System.out.println("Kanzensu!");
		} else {
		    System.out.println(n);
		}
   }
   
   static boolean isPrime(int n) {
       if (n <= 1) {
           return false;
       }
       for (int i = 2; i <= Math.sqrt(n); i++) {
           if (n % i == 0) {
               return false;
           }
       }
       return true;
   }
   
   static boolean isHeiho(int n ) {
       for (int i = 2; i * i <= n; i++) {
           if (i * i  == n) {
               return true;
           }
       }
       return false;
   }
 
    static boolean isRippo(int n ) {
       for (int i = 2; i * i * i <= n; i++) {
           if (i * i * i== n) {
               return true;
           }
       }
       return false;
   }
   
   static boolean isKanzen(int n) {
       int sum = 1;
       for (int i = 2; i < n; i++) {
           if (n % i == 0) {
               sum += i;
           }
       }
       return sum == n;
   }
  
   static int getCount(long n, int k) {
       int idx = 0;
       while (n > 0) {
           n -= (long)(Math.pow(k, idx));
           idx++;
       }
       return idx - 1;
   }
}

0