結果
問題 | No.2120 場合の数の下8桁 |
ユーザー |
|
提出日時 | 2023-11-09 22:41:20 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,049 bytes |
コンパイル時間 | 7,794 ms |
コンパイル使用メモリ | 165,240 KB |
実行使用メモリ | 276,828 KB |
最終ジャッジ日時 | 2024-09-26 00:37:51 |
合計ジャッジ時間 | 18,616 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 10 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (97 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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;}}