結果

問題 No.2120 場合の数の下8桁
ユーザー kuronikuroni
提出日時 2022-11-17 23:23:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,070 bytes
コンパイル時間 2,190 ms
コンパイル使用メモリ 170,064 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 13:21:24
合計ジャッジ時間 3,438 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 72 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 24 ms
4,348 KB
testcase_16 AC 78 ms
4,348 KB
testcase_17 AC 38 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 40 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;

const int N = 1E7 + 5;

using mint = static_modint<100000000>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int m, n; cin >> m >> n;
    mint num = 1, den = 1;
    mint ans;
    int p2 = 0, p5 = 0;
    if (n > m) {
        ans = 0;
    } else {
        for (int i = 1; i <= n; i++) {
            {
                int x = i;
                while (x % 2 == 0) {
                    p2--; x /= 2;
                }
                while (x % 5 == 0) {
                    p5--; x /= 5;
                }
                den *= x;
            }
            {
                int x = m - i + 1;
                while (x % 2 == 0) {
                    p2++; x /= 2;
                }
                while (x % 5 == 0) {
                    p5++; x /= 5;
                }
                num *= x;
            }
        }
        ans = num / den * mint(2).pow(p2) * mint(5).pow(p5);
    }
    cout << setfill('0') << setw(8) << ans.val();
}
0