結果
| 問題 |
No.1011 Infinite Stairs
|
| コンテスト | |
| ユーザー |
Strorkis
|
| 提出日時 | 2020-03-20 22:00:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 149 ms / 2,000 ms |
| コード長 | 856 bytes |
| コンパイル時間 | 572 ms |
| コンパイル使用メモリ | 66,076 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-17 11:49:55 |
| 合計ジャッジ時間 | 1,917 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <iostream>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
ll pow(ll a, ll n) {
ll res = 1;
for (; n; n >>= 1) {
if (n & 1) res = res * a % MOD;
a = a * a % MOD;
}
return res;
}
ll fact(int n) {
ll res = 1;
for (int i = 2; i <= n; i++)
res = res * i % MOD;
return res;
}
ll comb(ll n, ll r) {
ll tmp = 1;
for (int i = n; i > n - r; i--) tmp = tmp * i % MOD;
ll inv_fact_r = pow(fact(r), MOD-2);
return tmp * inv_fact_r % MOD;
}
ll hcomb(ll n, ll r) {
return comb(n+r-1, r);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, d, K; cin >> N >> d >> K;
ll ans = 0;
for (int i = 0; i <= (K-N)/d; i++) {
ans += pow(-1, i) * comb(N, i) * hcomb(N, K-N-d*i);
ans %= MOD;
while (ans < 0) ans += MOD;
}
cout << ans << "\n";
}
Strorkis