結果

問題 No.889 素数!
ユーザー bluemeganebluemegane
提出日時 2021-04-19 07:35:01
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 64,876 KB
実行使用メモリ 22,768 KB
最終ジャッジ日時 2023-09-17 08:14:50
合計ジャッジ時間 7,293 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,772 KB
testcase_01 AC 55 ms
20,668 KB
testcase_02 AC 54 ms
22,768 KB
testcase_03 AC 56 ms
20,600 KB
testcase_04 WA -
testcase_05 AC 53 ms
18,568 KB
testcase_06 AC 55 ms
20,652 KB
testcase_07 AC 54 ms
20,536 KB
testcase_08 AC 54 ms
22,740 KB
testcase_09 AC 53 ms
18,632 KB
testcase_10 AC 55 ms
20,680 KB
testcase_11 AC 53 ms
20,616 KB
testcase_12 AC 54 ms
20,672 KB
testcase_13 AC 54 ms
22,712 KB
testcase_14 AC 54 ms
18,692 KB
testcase_15 AC 56 ms
20,856 KB
testcase_16 AC 55 ms
22,728 KB
testcase_17 AC 55 ms
20,604 KB
testcase_18 AC 55 ms
22,668 KB
testcase_19 AC 55 ms
22,684 KB
testcase_20 AC 54 ms
20,612 KB
testcase_21 AC 55 ms
20,676 KB
testcase_22 AC 55 ms
22,708 KB
testcase_23 AC 54 ms
20,544 KB
testcase_24 AC 54 ms
22,716 KB
testcase_25 AC 55 ms
20,688 KB
testcase_26 AC 53 ms
20,792 KB
testcase_27 AC 54 ms
20,536 KB
testcase_28 AC 53 ms
18,628 KB
testcase_29 AC 54 ms
22,724 KB
testcase_30 AC 55 ms
20,740 KB
testcase_31 AC 55 ms
20,684 KB
testcase_32 AC 54 ms
20,664 KB
testcase_33 AC 54 ms
20,672 KB
testcase_34 AC 56 ms
20,692 KB
testcase_35 AC 55 ms
22,628 KB
testcase_36 AC 55 ms
22,584 KB
testcase_37 AC 53 ms
20,724 KB
testcase_38 AC 55 ms
20,764 KB
testcase_39 AC 54 ms
20,780 KB
testcase_40 AC 55 ms
22,560 KB
testcase_41 AC 55 ms
22,704 KB
testcase_42 AC 55 ms
22,724 KB
testcase_43 AC 55 ms
20,588 KB
testcase_44 AC 54 ms
20,612 KB
testcase_45 AC 54 ms
20,688 KB
testcase_46 AC 56 ms
20,856 KB
testcase_47 AC 53 ms
18,572 KB
testcase_48 AC 55 ms
22,748 KB
testcase_49 AC 53 ms
18,488 KB
testcase_50 AC 55 ms
20,688 KB
testcase_51 AC 55 ms
20,788 KB
testcase_52 AC 55 ms
20,720 KB
testcase_53 AC 54 ms
22,748 KB
testcase_54 AC 55 ms
22,636 KB
testcase_55 AC 55 ms
20,676 KB
testcase_56 AC 54 ms
20,580 KB
testcase_57 AC 54 ms
20,696 KB
testcase_58 AC 55 ms
20,660 KB
testcase_59 AC 54 ms
20,584 KB
testcase_60 AC 54 ms
20,632 KB
testcase_61 AC 54 ms
20,792 KB
testcase_62 AC 55 ms
22,724 KB
testcase_63 AC 57 ms
18,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        getAns(n);
    }
    static void getAns(int n)
    {
        string ans;
        if (IsPrime(n)) ans = "Sosu!";
        else if (n == 1 | n == 4 | n == 9 | n == 16 | n == 25 | n == 36 |
                   n == 49) ans = "Heihosu!";
        else if (n == 8 | n == 27) ans = "Ripposu!";
        else if (n == 6 | n == 28) ans = "Kanzensu!";
        else ans = n.ToString();
        Console.WriteLine(ans);
    }
    static bool IsPrime(int n)
    {
        if (n < 2) return false;
        else if (n == 2) return true;
        else if (n % 2 == 0) return false;
        double sqrtNum = Sqrt(n);
        for (int i = 3; i <= sqrtNum; i += 2)
            if (n % i == 0) return false;
        return true;
    }
}
0