結果

問題 No.1035 Color Box
ユーザー ashipanashipan
提出日時 2020-04-24 22:41:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 801 bytes
コンパイル時間 853 ms
コンパイル使用メモリ 74,360 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 03:42:42
合計ジャッジ時間 2,931 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 AC 2 ms
6,944 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
6,944 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
6,944 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;

ll combination(ll n, ll r){
    if(r > n - r) r = n - r;
    ll fact = 1, ifact = 1;
    rep(i, 0, r){
        fact *= (n - i);
        ifact *= (i + 1);
    }
    //cout << fact << " " << ifact << endl;
    return (fact/ifact) % mod;
}

ll factorial(ll n){
    ll fact = 1;
    rep(i, 0, n){
        fact = (fact*(n - i)) % mod;
    }
    return fact % mod;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    ans = combination(n, m);
    //cout << ans << endl;
    ans *= factorial(m);
    //cout << ans << endl;
    cout << ans % mod << endl;
    return 0;
}
0