結果
| 問題 |
No.503 配列コレクション
|
| コンテスト | |
| ユーザー |
TangentDay
|
| 提出日時 | 2017-04-08 00:02:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,629 bytes |
| コンパイル時間 | 870 ms |
| コンパイル使用メモリ | 81,784 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-16 03:28:07 |
| 合計ジャッジ時間 | 1,650 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 4 |
ソースコード
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define mod 1000000007
ll add(ll x, ll y){
return (x+y)%mod;
}
ll mul(ll x, ll y){
return (x%mod)*(y%mod)%mod;
}
ll powll(ll x, ll y){
ll res = 1LL;
while(y){
if (y & 1LL)
res *= x;
res %= mod;
x = (x*x) % mod;
y >>= 1LL;
}
return res;
}
ll divll(ll x, ll y){
return (x * powll(y,mod-2)) % mod;
}
ll nPr(ll n, ll r){
ll res = 1LL;
FOR(i,1,r){
res = (res * ((n-i+1) % mod)) % mod;
}
return res;
}
ll nCr(ll n, ll r){
ll res = nPr(n,r);
FOR(i,1,r){
res = (res * powll(i,mod-2)) % mod;
}
return res;
}
int main() {
ll n, k, d;
cin >> n >> k >> d;
ll x = (n-1)/(k-1), m = n - x*(k-1);
if(d == 1){
cout << m << endl;
return 0;
}
ll ans = 0, dd = 1;
ll ncr = nCr(m-2+x, x);
for (ll y = 0; y <= x; y++){
ans = (ans + dd * ncr) % mod;
dd = (dd * d) % mod;
ncr = (ncr * (x-y)) % mod;
ncr = divll(ncr, m-2+x-y);
}
ans = (ans * m) % mod;
cout << ans << endl;
return 0;
}
TangentDay