結果

問題 No.889 素数!
ユーザー ks2mks2m
提出日時 2019-09-20 22:38:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,061 bytes
コンパイル時間 3,098 ms
コンパイル使用メモリ 85,136 KB
実行使用メモリ 58,152 KB
最終ジャッジ日時 2023-10-12 20:17:08
合計ジャッジ時間 12,705 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,920 KB
testcase_01 AC 131 ms
56,208 KB
testcase_02 AC 122 ms
56,024 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 124 ms
56,044 KB
testcase_06 AC 122 ms
55,920 KB
testcase_07 AC 123 ms
56,300 KB
testcase_08 AC 126 ms
55,996 KB
testcase_09 AC 126 ms
56,140 KB
testcase_10 AC 123 ms
55,932 KB
testcase_11 AC 122 ms
55,740 KB
testcase_12 AC 124 ms
56,100 KB
testcase_13 AC 128 ms
55,556 KB
testcase_14 AC 125 ms
56,152 KB
testcase_15 AC 127 ms
56,292 KB
testcase_16 AC 122 ms
58,152 KB
testcase_17 AC 127 ms
55,880 KB
testcase_18 AC 123 ms
56,024 KB
testcase_19 AC 130 ms
56,112 KB
testcase_20 AC 123 ms
55,776 KB
testcase_21 AC 128 ms
55,880 KB
testcase_22 AC 129 ms
55,888 KB
testcase_23 AC 128 ms
56,268 KB
testcase_24 AC 124 ms
56,028 KB
testcase_25 AC 128 ms
55,900 KB
testcase_26 AC 126 ms
55,848 KB
testcase_27 AC 127 ms
56,192 KB
testcase_28 AC 124 ms
55,784 KB
testcase_29 AC 129 ms
55,868 KB
testcase_30 AC 123 ms
55,952 KB
testcase_31 AC 129 ms
56,160 KB
testcase_32 AC 124 ms
56,012 KB
testcase_33 AC 130 ms
56,196 KB
testcase_34 AC 128 ms
56,104 KB
testcase_35 AC 128 ms
55,836 KB
testcase_36 AC 129 ms
56,148 KB
testcase_37 AC 124 ms
55,724 KB
testcase_38 AC 129 ms
56,084 KB
testcase_39 AC 129 ms
55,896 KB
testcase_40 AC 129 ms
56,292 KB
testcase_41 AC 124 ms
56,020 KB
testcase_42 AC 128 ms
55,872 KB
testcase_43 AC 125 ms
55,988 KB
testcase_44 AC 128 ms
55,984 KB
testcase_45 AC 128 ms
56,212 KB
testcase_46 AC 128 ms
55,504 KB
testcase_47 AC 122 ms
56,068 KB
testcase_48 AC 129 ms
54,272 KB
testcase_49 AC 120 ms
55,696 KB
testcase_50 AC 125 ms
54,064 KB
testcase_51 AC 125 ms
55,692 KB
testcase_52 AC 126 ms
55,860 KB
testcase_53 AC 123 ms
55,692 KB
testcase_54 AC 129 ms
55,824 KB
testcase_55 AC 127 ms
55,820 KB
testcase_56 AC 129 ms
55,628 KB
testcase_57 AC 129 ms
56,340 KB
testcase_58 AC 128 ms
56,008 KB
testcase_59 AC 124 ms
55,700 KB
testcase_60 AC 128 ms
55,884 KB
testcase_61 AC 124 ms
55,832 KB
testcase_62 AC 127 ms
56,308 KB
testcase_63 AC 128 ms
56,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();

		if (isSosuu(n)) {
			System.out.println("Sosu!");
			return;
		}

		int n2 = (int) Math.sqrt(n);
		if (n > 1 && n2 * n2 == n) {
			System.out.println("Heihosu!");
			return;
		}

		if (n == 8 || n == 27 || n == 64) {
			System.out.println("Ripposu!");
			return;
		}

		List<Long> list = new ArrayList<>();
		long end = (long) Math.sqrt(n);
		for (int i = 1; i <= end; i++) {
			if (n % i == 0) {
				list.add((long) i);
			}
		}
		int i = end * end == n ? list.size() - 2 : list.size() - 1;
		for ( ; i >= 0; i--) {
			list.add(n / list.get(i));
		}
		if (list.stream().mapToLong(a -> a).sum() == n * 2) {
			System.out.println("Kanzensu!");
			return;
		}

		System.out.println(n);
	}

	static boolean isSosuu(long n) {
		for (int i = 2; i < n; i++) {
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}
}
0