結果

問題 No.503 配列コレクション
ユーザー Kmcode1Kmcode1
提出日時 2017-04-07 22:50:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,469 bytes
コンパイル時間 1,990 ms
コンパイル使用メモリ 147,064 KB
実行使用メモリ 42,416 KB
最終ジャッジ日時 2023-09-23 02:22:08
合計ジャッジ時間 10,096 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 297 ms
42,080 KB
testcase_01 WA -
testcase_02 AC 298 ms
42,128 KB
testcase_03 AC 297 ms
42,072 KB
testcase_04 WA -
testcase_05 AC 297 ms
42,068 KB
testcase_06 AC 295 ms
42,376 KB
testcase_07 AC 297 ms
42,212 KB
testcase_08 AC 297 ms
42,012 KB
testcase_09 AC 297 ms
42,280 KB
testcase_10 AC 297 ms
42,008 KB
testcase_11 AC 297 ms
42,116 KB
testcase_12 AC 297 ms
42,044 KB
testcase_13 AC 298 ms
42,144 KB
testcase_14 AC 297 ms
42,132 KB
testcase_15 AC 299 ms
42,132 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 298 ms
42,200 KB
testcase_19 WA -
testcase_20 AC 297 ms
42,080 KB
testcase_21 WA -
testcase_22 AC 298 ms
42,244 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;


#define MAX 1000002

int n;
int k;
int d;

#define MOD 1000000007

long long int p[MAX];



class Combination{
	long long int ppow(long long int i, long long int j){
		long long int res = 1LL;
		while (j){
			if ((j & 1LL)){
				res *= i;
				if (res >= MOD){
					res %= MOD;
				}
			}
			j >>= 1;
			i *= i;
			if (i >= MOD){
				i %= MOD;
			}
		}
		return res;
	}
public:
	vector<long long int> k;
	vector<long long int> r;
	void resize(int N){
		k.resize(N + 2);
		r.resize(N + 2);
		k[0] = 1;
		for (int i = 1; i < k.size(); i++){
			k[i] = k[i - 1];
			k[i] *= i;
			if (k[i] >= MOD)k[i] %= MOD;
		}
		for (int i = 0; i < r.size(); i++){
			r[i] = ppow(k[i], MOD - 2);
		}
	}
	long long int C(int a, int b){
		if (a < b)return 0;
		long long int up = k[a];
		long long int dw = r[b] * r[a - b];
		dw %= MOD;
		up *= dw;
		up %= MOD;
		return up;
	}
	long long int H(int a, int b){
		return C(a + b - 1, b);
	}
} c;

int main(){
	c.resize(MAX * 2);
	cin >> n >> k >> d;
	p[0] = 1;
	for (int i = 1; i < MAX; i++){
		p[i] = p[i - 1];
		p[i] *= d;
		p[i] %= MOD;
	}
	int op = 0;
	while (n >= k){
		n -= k - 1;
		op++;
	}
	long long int ans = 0;
	for (int i = 1; i <= 1; i++){
		for (int j = 0; j <= op; j++){
			long long int w = c.H(n - 1, op-j);
			w *= p[j];
			w %= MOD;
			w *= n;
			w %= MOD;
			ans += w;
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
	return 0;
}
0