結果
問題 |
No.2120 場合の数の下8桁
|
ユーザー |
![]() |
提出日時 | 2022-11-04 22:17:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,331 bytes |
コンパイル時間 | 3,291 ms |
コンパイル使用メモリ | 246,704 KB |
最終ジャッジ日時 | 2025-02-08 17:56:27 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 RE * 3 |
ソースコード
#include <bits/extc++.h> int main() { using namespace std; unsigned long M, N; cin >> M >> N; unsigned long value{1}, ord_2{}, ord_5{}; if(N > M - N)N = M - N; const auto multiplies{[&value, &ord_2, &ord_5](unsigned long x){ while(x && x % 2 == 0){ ++ord_2; x /= 2; } while(x && x % 5 == 0){ ++ord_5; x /= 5; } (value *= x) %= 100000000; }}; const auto divides{[&value, &ord_2, &ord_5](unsigned long x){ while(x && x % 2 == 0){ --ord_2; x /= 2; } while(x && x % 5 == 0){ --ord_5; x /= 5; } (value *= [](unsigned long a, unsigned long n){ unsigned long r{1}; while(n){ if(n & 1)(r *= a) %= 100000000; (a *= a) %= 100000000; n /= 2; } return r; }(x, 4999999)) %= 100000000; }}; for(unsigned long i{}; i < N; ++i){ multiplies(M - i); divides(i + 1); } assert(ord_2 < M && ord_5 < M); while(ord_2 > 0){ --ord_2; (value *= 2) %= 100000000; } while(ord_5 > 0){ --ord_5; (value *= 5) %= 100000000; } printf("%08lu\n", value); return 0; }