結果

問題 No.1126 SUM
ユーザー Hydrogen332
提出日時 2024-10-28 20:45:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 698 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 192,268 KB
最終ジャッジ日時 2025-02-25 01:07:54
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i)
#define all(a) (a).begin(), (a).end()

const ll mod = 1e9 + 7;

ll modpow(ll a, ll n, ll m) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll m) {
    return modpow(a, m - 2, m);
}

int main() {
    cin.tie(nullptr);
    
    ll N, M;
    cin >> N >> M;
    
    ll ans = 1;
    rep(i, 0, N + 1) {
        ans *= M + 1 - i;
        ans %= mod;
    }
    rep(i, 1, N + 2) {
        ans *= modinv(i, mod);
        ans %= mod;
    }
    
    cout << ans << '\n';
}
0