結果

問題 No.1035 Color Box
ユーザー iqueue02iqueue02
提出日時 2020-04-24 21:52:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 1,404 ms
コンパイル使用メモリ 165,348 KB
実行使用メモリ 15,672 KB
最終ジャッジ日時 2023-08-05 04:52:37
合計ジャッジ時間 3,427 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

const int MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int n, m;
  cin >> n >> m;
  ll d = m;
  for (int i = 1; i < m; i++) {
    d *= (ll)(m - i);
    d %= MOD;
  } 
  //cout << d << endl;
  COMinit();
  cout << d * COM(m+1, n - m) % MOD << endl;
  return 0; 
} 
0