結果

問題 No.2120 場合の数の下8桁
ユーザー 👑 kakel-sankakel-san
提出日時 2023-11-09 22:41:20
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 2,049 bytes
コンパイル時間 9,571 ms
コンパイル使用メモリ 158,928 KB
実行使用メモリ 268,008 KB
最終ジャッジ日時 2023-11-09 22:41:38
合計ジャッジ時間 17,508 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
34,852 KB
testcase_01 AC 77 ms
34,852 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 75 ms
34,852 KB
testcase_06 AC 76 ms
34,852 KB
testcase_07 AC 59 ms
31,524 KB
testcase_08 AC 60 ms
31,524 KB
testcase_09 AC 77 ms
34,852 KB
testcase_10 AC 76 ms
34,852 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1,974 ms
118,352 KB
testcase_18 AC 62 ms
31,524 KB
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (101 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var m = NN;
        var n = NN;
        if (m < n)
        {
            WriteLine("00000000");
            return;
        }
        var begin = DateTime.Now;
        if (n > m / 2) n = m - n;
        var mod = 100_000_000;
        var ans = 1L;
        var count2 = 0;
        var count5 = 0;
        var dic = new Dictionary<int, int>();
        for (var i = 0; i < n; ++i)
        {
            var ch = m - i;
            while (ch % 2 == 0)
            {
                ++count2;
                ch /= 2;
            }
            while (ch % 5 == 0)
            {
                ++count5;
                ch /= 5;
            }
            ans = ans * ch % mod;
            var pa = i + 1;
            while (pa % 2 == 0)
            {
                --count2;
                pa /= 2;
            }
            while (pa % 5 == 0)
            {
                --count5;
                pa /= 5;
            }
            if (dic.ContainsKey(pa)) ans = ans * dic[pa] % mod;
            else
            {
                var rev = (int)Exp(pa, mod - 2, mod);
                dic[pa] = rev;
                ans = ans * rev % mod;
            }
        }
        ans = ans * Exp(2, count2, mod) % mod * Exp(5, count5, mod) % mod;
        WriteLine(ans.ToString("00000000"));
    }
    static long Exp(long n, long p, int mod)
    {
        long _n = n % mod;
        var _p = p;
        var result = 1L;
        if ((_p & 1) == 1) result *= _n;
        while (_p > 0)
        {
            _n = _n * _n % mod;
            _p >>= 1;
            if ((_p & 1) == 1) result = result * _n % mod;
        }
        return result;
    }
}
0