結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,856 KB
testcase_01 AC 129 ms
55,688 KB
testcase_02 AC 128 ms
56,144 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 122 ms
56,224 KB
testcase_06 AC 125 ms
54,024 KB
testcase_07 AC 126 ms
56,028 KB
testcase_08 AC 124 ms
56,236 KB
testcase_09 AC 123 ms
55,976 KB
testcase_10 AC 126 ms
56,004 KB
testcase_11 AC 127 ms
56,064 KB
testcase_12 AC 122 ms
56,168 KB
testcase_13 AC 126 ms
55,928 KB
testcase_14 AC 122 ms
55,776 KB
testcase_15 AC 126 ms
56,008 KB
testcase_16 AC 126 ms
55,724 KB
testcase_17 AC 123 ms
55,544 KB
testcase_18 AC 126 ms
56,152 KB
testcase_19 AC 124 ms
55,752 KB
testcase_20 AC 123 ms
56,020 KB
testcase_21 AC 123 ms
56,328 KB
testcase_22 AC 123 ms
55,548 KB
testcase_23 AC 122 ms
56,236 KB
testcase_24 AC 124 ms
56,200 KB
testcase_25 AC 123 ms
55,964 KB
testcase_26 AC 123 ms
56,160 KB
testcase_27 AC 123 ms
55,920 KB
testcase_28 AC 122 ms
56,296 KB
testcase_29 AC 123 ms
56,368 KB
testcase_30 AC 122 ms
56,508 KB
testcase_31 AC 128 ms
55,788 KB
testcase_32 AC 126 ms
56,280 KB
testcase_33 AC 121 ms
56,044 KB
testcase_34 AC 122 ms
56,268 KB
testcase_35 AC 121 ms
55,492 KB
testcase_36 AC 121 ms
56,168 KB
testcase_37 AC 121 ms
55,708 KB
testcase_38 AC 121 ms
56,208 KB
testcase_39 AC 126 ms
55,504 KB
testcase_40 AC 123 ms
56,096 KB
testcase_41 AC 120 ms
56,008 KB
testcase_42 AC 123 ms
56,060 KB
testcase_43 AC 122 ms
56,136 KB
testcase_44 AC 125 ms
56,168 KB
testcase_45 AC 123 ms
56,160 KB
testcase_46 AC 123 ms
56,120 KB
testcase_47 AC 123 ms
56,352 KB
testcase_48 AC 123 ms
55,784 KB
testcase_49 AC 122 ms
55,860 KB
testcase_50 AC 115 ms
55,776 KB
testcase_51 AC 122 ms
55,548 KB
testcase_52 AC 121 ms
55,712 KB
testcase_53 AC 122 ms
55,544 KB
testcase_54 AC 124 ms
56,076 KB
testcase_55 AC 124 ms
56,184 KB
testcase_56 AC 120 ms
55,944 KB
testcase_57 AC 120 ms
55,872 KB
testcase_58 AC 122 ms
55,992 KB
testcase_59 AC 121 ms
55,880 KB
testcase_60 AC 124 ms
56,136 KB
testcase_61 AC 125 ms
56,220 KB
testcase_62 AC 125 ms
55,724 KB
testcase_63 AC 122 ms
55,912 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) {
       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