結果

問題 No.129 お年玉(2)
ユーザー mbanmban
提出日時 2017-01-12 16:48:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,278 ms / 5,000 ms
コード長 2,113 bytes
コンパイル時間 2,988 ms
コンパイル使用メモリ 105,956 KB
実行使用メモリ 402,080 KB
最終ジャッジ日時 2023-08-18 17:48:59
合計ジャッジ時間 33,696 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
45,968 KB
testcase_01 AC 1,263 ms
402,080 KB
testcase_02 AC 54 ms
22,696 KB
testcase_03 AC 52 ms
20,644 KB
testcase_04 AC 54 ms
18,724 KB
testcase_05 AC 571 ms
187,164 KB
testcase_06 AC 821 ms
251,104 KB
testcase_07 AC 1,018 ms
324,844 KB
testcase_08 AC 706 ms
224,668 KB
testcase_09 AC 925 ms
288,008 KB
testcase_10 AC 1,046 ms
337,436 KB
testcase_11 AC 682 ms
217,216 KB
testcase_12 AC 859 ms
261,044 KB
testcase_13 AC 922 ms
281,320 KB
testcase_14 AC 884 ms
267,460 KB
testcase_15 AC 740 ms
228,260 KB
testcase_16 AC 837 ms
249,392 KB
testcase_17 AC 1,011 ms
316,036 KB
testcase_18 AC 940 ms
291,224 KB
testcase_19 AC 1,006 ms
320,624 KB
testcase_20 AC 994 ms
314,988 KB
testcase_21 AC 1,245 ms
393,720 KB
testcase_22 AC 716 ms
224,136 KB
testcase_23 AC 1,099 ms
345,008 KB
testcase_24 AC 1,047 ms
332,436 KB
testcase_25 AC 700 ms
217,836 KB
testcase_26 AC 709 ms
221,132 KB
testcase_27 AC 686 ms
214,936 KB
testcase_28 AC 1,246 ms
399,184 KB
testcase_29 AC 53 ms
20,864 KB
testcase_30 AC 51 ms
20,644 KB
testcase_31 AC 52 ms
20,652 KB
testcase_32 AC 51 ms
20,688 KB
testcase_33 AC 59 ms
24,780 KB
testcase_34 AC 54 ms
20,664 KB
testcase_35 AC 58 ms
24,900 KB
testcase_36 AC 59 ms
22,692 KB
testcase_37 AC 64 ms
28,960 KB
testcase_38 AC 195 ms
76,936 KB
testcase_39 AC 269 ms
91,280 KB
testcase_40 AC 648 ms
206,032 KB
testcase_41 AC 422 ms
147,708 KB
testcase_42 AC 207 ms
79,472 KB
testcase_43 AC 206 ms
80,848 KB
testcase_44 AC 1,278 ms
399,064 KB
testcase_45 AC 138 ms
54,552 KB
testcase_46 AC 289 ms
102,780 KB
testcase_47 AC 1,215 ms
389,196 KB
testcase_48 AC 731 ms
234,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static private Magatro M = new Magatro();
    static private void Main(string[]args)
    {
        M.Scan();
        M.Solve();
    }
}

public class Scanner
{
    private string[] S;
    private int Index;
    private char Separator;

    public Scanner(char separator = ' ')
    {
        Index = 0;
        Separator = separator;
    }

    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (S == null || Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}

public class Magatro
{
    private long N;
    private int M;
    private const int Mod = 1000000000;
    public void Scan()
    {
        Scanner sc = new Scanner();
        N = sc.NextLong()/1000;
        M = sc.NextInt();
    }

    public void Solve()
    {
        N %= M;
        Console.WriteLine(Conbination());
    }
    private long Conbination()
    {
        List<int>[] TryAngle = new List<int>[M + 1];
        TryAngle[0] = new List<int>();
        TryAngle[0].Add(1);
        for(int i = 1; i <= M; i++)
        {
            TryAngle[i] = new List<int>();
            for(int j = 0; j < TryAngle[i - 1].Count+1; j++)
            {
                if (j == 0||j==TryAngle[i-1].Count)
                {
                    TryAngle[i].Add(1);
                }
                else
                {
                    TryAngle[i].Add((TryAngle[i - 1][j - 1] + TryAngle[i - 1][j])%Mod);
                }
            }
        }
        return TryAngle[M][(int)N];
    }
}
0