結果
| 問題 |
No.741 AscNumber(Easy)
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2018-10-05 21:31:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 1,115 bytes |
| コンパイル時間 | 1,768 ms |
| コンパイル使用メモリ | 169,620 KB |
| 実行使用メモリ | 18,816 KB |
| 最終ジャッジ日時 | 2024-10-12 12:52:56 |
| 合計ジャッジ時間 | 3,322 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 55 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }
const lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }
inline lint invm(lint a, lint p = mod) { a %= p; return a == 1 ? 1 : -p / a * invm(p % a) % p; }
V<lint> fact, ifact;
void init_table(int n) {
fact.assign(n + 1, 1), ifact.assign(n + 1, 1);
for (int i = 2; i < n + 1; i++) fact[i] = i * fact[i - 1] % mod;
ifact[n] = invm(fact[n]);
for (int i = n; i > 2; i--) ifact[i - 1] = i * ifact[i] % mod;
}
lint mulcomb(lint n, lint r) {
if (n < 1 or r < 0) return 0;
return fact[r + n - 1] * ifact[r] % mod * ifact[n - 1] % mod;
}
int main() {
cin.tie(NULL); ios::sync_with_stdio(false);
lint n; cin >> n;
init_table(n + 20);
lint res = mulcomb(10, n);
cout << emod(res) << '\n';
}
risujiroh