結果

問題 No.634 硬貨の枚数1
ユーザー bluemeganebluemegane
提出日時 2018-09-09 18:42:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 2,486 ms
コンパイル使用メモリ 102,340 KB
実行使用メモリ 22,964 KB
最終ジャッジ日時 2023-08-25 13:14:51
合計ジャッジ時間 11,959 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,684 KB
testcase_01 AC 55 ms
20,672 KB
testcase_02 AC 56 ms
20,868 KB
testcase_03 AC 55 ms
20,676 KB
testcase_04 AC 56 ms
20,584 KB
testcase_05 AC 55 ms
22,652 KB
testcase_06 AC 55 ms
20,680 KB
testcase_07 AC 55 ms
20,724 KB
testcase_08 AC 55 ms
20,704 KB
testcase_09 AC 55 ms
20,668 KB
testcase_10 AC 55 ms
22,660 KB
testcase_11 AC 55 ms
22,756 KB
testcase_12 AC 55 ms
22,660 KB
testcase_13 AC 55 ms
20,800 KB
testcase_14 AC 61 ms
22,684 KB
testcase_15 AC 89 ms
20,612 KB
testcase_16 AC 71 ms
20,632 KB
testcase_17 AC 76 ms
20,752 KB
testcase_18 AC 69 ms
20,720 KB
testcase_19 AC 58 ms
20,748 KB
testcase_20 AC 62 ms
22,760 KB
testcase_21 AC 96 ms
20,680 KB
testcase_22 AC 91 ms
20,796 KB
testcase_23 AC 70 ms
20,744 KB
testcase_24 AC 55 ms
18,696 KB
testcase_25 AC 55 ms
22,704 KB
testcase_26 AC 55 ms
20,616 KB
testcase_27 AC 53 ms
18,752 KB
testcase_28 AC 55 ms
20,576 KB
testcase_29 AC 55 ms
20,548 KB
testcase_30 AC 55 ms
20,760 KB
testcase_31 AC 56 ms
22,664 KB
testcase_32 AC 55 ms
20,684 KB
testcase_33 AC 55 ms
20,624 KB
testcase_34 AC 58 ms
20,628 KB
testcase_35 AC 68 ms
20,800 KB
testcase_36 AC 84 ms
22,624 KB
testcase_37 AC 73 ms
20,720 KB
testcase_38 AC 60 ms
20,800 KB
testcase_39 AC 93 ms
20,572 KB
testcase_40 AC 81 ms
20,668 KB
testcase_41 AC 78 ms
22,780 KB
testcase_42 AC 90 ms
20,556 KB
testcase_43 AC 68 ms
20,616 KB
testcase_44 AC 55 ms
20,680 KB
testcase_45 AC 56 ms
20,664 KB
testcase_46 AC 58 ms
20,536 KB
testcase_47 AC 74 ms
22,656 KB
testcase_48 AC 54 ms
20,616 KB
testcase_49 AC 56 ms
22,716 KB
testcase_50 AC 100 ms
20,928 KB
testcase_51 AC 60 ms
20,628 KB
testcase_52 AC 55 ms
20,616 KB
testcase_53 AC 55 ms
20,716 KB
testcase_54 AC 55 ms
20,688 KB
testcase_55 AC 99 ms
20,712 KB
testcase_56 AC 99 ms
20,608 KB
testcase_57 AC 96 ms
22,648 KB
testcase_58 AC 99 ms
20,636 KB
testcase_59 AC 98 ms
20,668 KB
testcase_60 AC 96 ms
20,708 KB
testcase_61 AC 97 ms
20,752 KB
testcase_62 AC 99 ms
20,656 KB
testcase_63 AC 100 ms
22,760 KB
testcase_64 AC 98 ms
20,568 KB
testcase_65 AC 98 ms
22,796 KB
testcase_66 AC 101 ms
20,688 KB
testcase_67 AC 101 ms
22,964 KB
testcase_68 AC 98 ms
20,716 KB
testcase_69 AC 100 ms
22,636 KB
testcase_70 AC 99 ms
20,616 KB
testcase_71 AC 98 ms
18,568 KB
testcase_72 AC 100 ms
20,764 KB
testcase_73 AC 100 ms
20,672 KB
testcase_74 AC 98 ms
20,800 KB
testcase_75 AC 98 ms
22,660 KB
testcase_76 AC 55 ms
20,680 KB
testcase_77 AC 54 ms
20,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    public static void Main()
    {
        var c = getC();
        var n = int.Parse(Console.ReadLine().Trim());
        if (n == 1) { Console.WriteLine(1); goto end; }
        var a = getP(c, n);
        if (c[a] == n) { Console.WriteLine(1); goto end; }
        var cL = c.Length;
        for (int i = 0; i <= a; i++)
            for (int j = 0; j <= a; j++)
                if (c[i] + c[j] == n) { Console.WriteLine(2); goto end; }
        Console.WriteLine(3);
        end:;
    }
    public static int[] getC()
    {
        var c = new int[4471];
        for (int i = 1; i <= 4471; i++)
            c[i - 1] = i * (i + 1) / 2;
        return c;
    }
    public static int getP(int[] c, int n)
    {
        var ng = 0; var ok = c.Length - 1;
        while (ok - ng > 1)
        {
            var mid = ng + (ok - ng) / 2;
            if (c[mid] >= n) ok = mid;
            else ng = mid;
        }
        return ok;
    }
}
0