結果

問題 No.889 素数!
ユーザー htensaihtensai
提出日時 2020-02-13 18:06:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,365 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 77,900 KB
実行使用メモリ 54,384 KB
最終ジャッジ日時 2024-04-15 23:16:37
合計ジャッジ時間 11,615 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
40,044 KB
testcase_01 AC 117 ms
40,704 KB
testcase_02 AC 126 ms
41,360 KB
testcase_03 AC 123 ms
41,020 KB
testcase_04 WA -
testcase_05 AC 125 ms
41,692 KB
testcase_06 AC 113 ms
40,216 KB
testcase_07 AC 130 ms
41,720 KB
testcase_08 AC 115 ms
39,988 KB
testcase_09 WA -
testcase_10 AC 116 ms
40,272 KB
testcase_11 AC 128 ms
41,436 KB
testcase_12 AC 113 ms
40,036 KB
testcase_13 AC 114 ms
39,892 KB
testcase_14 AC 126 ms
41,516 KB
testcase_15 AC 125 ms
41,364 KB
testcase_16 AC 123 ms
41,348 KB
testcase_17 AC 116 ms
40,708 KB
testcase_18 AC 123 ms
41,152 KB
testcase_19 AC 124 ms
41,420 KB
testcase_20 AC 126 ms
41,180 KB
testcase_21 AC 121 ms
41,756 KB
testcase_22 AC 130 ms
41,616 KB
testcase_23 AC 127 ms
41,204 KB
testcase_24 AC 113 ms
40,208 KB
testcase_25 AC 126 ms
41,228 KB
testcase_26 AC 117 ms
40,292 KB
testcase_27 AC 128 ms
41,048 KB
testcase_28 AC 115 ms
40,008 KB
testcase_29 WA -
testcase_30 AC 126 ms
41,212 KB
testcase_31 AC 122 ms
41,448 KB
testcase_32 AC 127 ms
41,272 KB
testcase_33 AC 129 ms
41,388 KB
testcase_34 AC 114 ms
40,164 KB
testcase_35 AC 125 ms
41,160 KB
testcase_36 AC 128 ms
41,300 KB
testcase_37 AC 114 ms
40,092 KB
testcase_38 AC 126 ms
41,436 KB
testcase_39 AC 128 ms
41,180 KB
testcase_40 AC 119 ms
40,500 KB
testcase_41 AC 114 ms
40,216 KB
testcase_42 AC 124 ms
41,400 KB
testcase_43 AC 121 ms
41,116 KB
testcase_44 AC 126 ms
41,372 KB
testcase_45 AC 127 ms
41,596 KB
testcase_46 AC 112 ms
40,232 KB
testcase_47 AC 113 ms
40,348 KB
testcase_48 AC 128 ms
41,644 KB
testcase_49 AC 126 ms
41,012 KB
testcase_50 AC 112 ms
40,036 KB
testcase_51 AC 115 ms
40,084 KB
testcase_52 AC 126 ms
41,552 KB
testcase_53 AC 120 ms
40,712 KB
testcase_54 AC 128 ms
41,264 KB
testcase_55 AC 126 ms
41,224 KB
testcase_56 AC 115 ms
40,036 KB
testcase_57 AC 114 ms
40,340 KB
testcase_58 AC 128 ms
41,336 KB
testcase_59 AC 116 ms
40,328 KB
testcase_60 AC 126 ms
41,016 KB
testcase_61 AC 114 ms
40,220 KB
testcase_62 AC 123 ms
41,144 KB
testcase_63 AC 114 ms
40,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		if (isPrime(n)) {
		    ans += 1;
		}
		if (isDbl(n)) {
		    ans += 2;
		}
		if (isTr(n)) {
		    ans += 4;
		}
		if (isPerf(n)) {
		    ans += 8;
		}
		String str;
		if (ans == 1) {
		    str = "Sosu!";
		} else if (ans == 2) {
		    str = "Heihosu!";
		} else if (ans == 4) {
		    str = "Ripposu!";
		} else if (ans == 8) {
		    str = "Kanzensu!";
		} else {
		    str = String.valueOf(n);
		}
		System.out.println(str);
   }
   
   static boolean isPrime(int x) {
       for (int i = 2; i <= Math.sqrt(x); i++) {
           if (x % i == 0) {
               return false;
           }
       }
       return true;
   }
   
   static boolean isDbl(int x) {
       for (int i = 2; i * i <= x; i++) {
           if (i * i == x) {
               return true;
           }
       }
       return false;
   }
   
   static boolean isTr(int x) {
       for (int i = 2; i * i * i <= x; i++) {
           if (i * i * i == x) {
               return true;
           }
       }
       return false;
   }
   
   static boolean isPerf(int x) {
       int sum = 0;
       for (int i = 2; i < x; i++) {
           if (x % i == 0) {
               sum += i;
           }
       }
       return sum == x;
   }
}
0