結果
問題 | No.1035 Color Box |
ユーザー |
![]() |
提出日時 | 2020-04-24 22:41:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 801 bytes |
コンパイル時間 | 595 ms |
コンパイル使用メモリ | 74,052 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-15 03:15:19 |
合計ジャッジ時間 | 3,145 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 20 RE * 10 |
ソースコード
#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;}