結果

問題 No.129 お年玉(2)
ユーザー mban
提出日時 2017-01-12 16:48:47
言語 C#
(mono 4.6.2)
結果
AC  
実行時間 1313 ms
コード長 2113 Byte
コンパイル時間 296 ms
使用メモリ 391704 KB

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
challenge01.txt AC 1290 ms
391704 KB
sample1.txt AC 28 ms
12636 KB
sample2.txt AC 29 ms
12636 KB
sample3.txt AC 27 ms
12628 KB
system_test1.txt AC 546 ms
174660 KB
system_test2.txt AC 817 ms
240300 KB
system_test3.txt AC 1018 ms
314276 KB
system_test4.txt AC 711 ms
212352 KB
system_test5.txt AC 931 ms
277564 KB
system_test6.txt AC 1060 ms
325016 KB
system_test7.txt AC 682 ms
206672 KB
system_test8.txt AC 851 ms
250580 KB
system_test9.txt AC 921 ms
268888 KB
system_test10.txt AC 879 ms
255080 KB
system_test11.txt AC 731 ms
217948 KB
system_test12.txt AC 818 ms
238740 KB
system_test13.txt AC 1058 ms
305700 KB
system_test14.txt AC 971 ms
278584 KB
system_test15.txt AC 1168 ms
308220 KB
system_test16.txt AC 1030 ms
304548 KB
system_test17.txt AC 1313 ms
383324 KB
system_test18.txt AC 716 ms
213848 KB
system_test19.txt AC 1129 ms
334632 KB
system_test20.txt AC 1080 ms
321872 KB
system_test21.txt AC 686 ms
207480 KB
system_test22.txt AC 710 ms
210776 KB
system_test23.txt AC 673 ms
206608 KB
system_test24.txt AC 1291 ms
386656 KB
test1.txt AC 28 ms
12628 KB
test2.txt AC 28 ms
12620 KB
test3.txt AC 28 ms
12632 KB
test4.txt AC 27 ms
12640 KB
test5.txt AC 35 ms
14292 KB
test6.txt AC 29 ms
12640 KB
test7.txt AC 33 ms
13808 KB
test8.txt AC 34 ms
14336 KB
test9.txt AC 38 ms
17028 KB
test10.txt AC 177 ms
62576 KB
test11.txt AC 251 ms
79044 KB
test12.txt AC 666 ms
197688 KB
test13.txt AC 425 ms
135320 KB
test14.txt AC 188 ms
67124 KB
test15.txt AC 184 ms
66488 KB
test16.txt AC 1298 ms
388840 KB
test17.txt AC 120 ms
44252 KB
test18.txt AC 277 ms
90352 KB
test19.txt AC 1229 ms
376780 KB
test20.txt AC 723 ms
219900 KB
テストケース一括ダウンロード

ソースコード

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