結果

問題 No.889 素数!
ユーザー htensaihtensai
提出日時 2019-12-07 11:23:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,466 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 74,240 KB
実行使用メモリ 56,400 KB
最終ジャッジ日時 2023-08-26 05:44:38
合計ジャッジ時間 13,934 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
56,024 KB
testcase_01 AC 109 ms
56,124 KB
testcase_02 AC 109 ms
56,180 KB
testcase_03 AC 112 ms
55,944 KB
testcase_04 WA -
testcase_05 AC 110 ms
55,704 KB
testcase_06 AC 108 ms
55,768 KB
testcase_07 AC 111 ms
56,324 KB
testcase_08 AC 108 ms
55,700 KB
testcase_09 AC 106 ms
55,948 KB
testcase_10 AC 107 ms
55,708 KB
testcase_11 AC 116 ms
55,872 KB
testcase_12 AC 112 ms
56,128 KB
testcase_13 AC 117 ms
56,108 KB
testcase_14 AC 112 ms
56,044 KB
testcase_15 AC 112 ms
55,996 KB
testcase_16 AC 112 ms
56,112 KB
testcase_17 AC 108 ms
55,928 KB
testcase_18 AC 110 ms
55,960 KB
testcase_19 AC 106 ms
55,608 KB
testcase_20 AC 109 ms
55,844 KB
testcase_21 AC 108 ms
56,100 KB
testcase_22 AC 110 ms
56,072 KB
testcase_23 AC 109 ms
55,696 KB
testcase_24 AC 111 ms
55,748 KB
testcase_25 AC 109 ms
56,024 KB
testcase_26 AC 113 ms
55,748 KB
testcase_27 AC 110 ms
55,980 KB
testcase_28 AC 107 ms
55,776 KB
testcase_29 AC 108 ms
55,516 KB
testcase_30 AC 106 ms
55,940 KB
testcase_31 AC 110 ms
55,708 KB
testcase_32 AC 108 ms
55,624 KB
testcase_33 AC 111 ms
56,016 KB
testcase_34 AC 111 ms
55,672 KB
testcase_35 AC 110 ms
55,852 KB
testcase_36 AC 105 ms
55,992 KB
testcase_37 AC 108 ms
56,276 KB
testcase_38 AC 110 ms
55,756 KB
testcase_39 AC 111 ms
56,004 KB
testcase_40 AC 110 ms
56,400 KB
testcase_41 AC 111 ms
54,312 KB
testcase_42 AC 106 ms
55,672 KB
testcase_43 AC 108 ms
55,752 KB
testcase_44 AC 109 ms
56,016 KB
testcase_45 AC 108 ms
55,716 KB
testcase_46 AC 107 ms
55,880 KB
testcase_47 AC 111 ms
56,144 KB
testcase_48 AC 110 ms
55,524 KB
testcase_49 AC 112 ms
55,812 KB
testcase_50 AC 105 ms
55,948 KB
testcase_51 AC 111 ms
55,968 KB
testcase_52 AC 107 ms
56,092 KB
testcase_53 AC 109 ms
56,060 KB
testcase_54 AC 107 ms
55,844 KB
testcase_55 AC 109 ms
55,520 KB
testcase_56 AC 110 ms
56,020 KB
testcase_57 AC 110 ms
56,168 KB
testcase_58 AC 107 ms
55,976 KB
testcase_59 AC 109 ms
55,932 KB
testcase_60 AC 109 ms
56,224 KB
testcase_61 AC 109 ms
55,704 KB
testcase_62 AC 108 ms
55,764 KB
testcase_63 AC 110 ms
53,764 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 (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