結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 296 ms
42,084 KB
testcase_01 AC 295 ms
42,068 KB
testcase_02 AC 295 ms
42,136 KB
testcase_03 AC 296 ms
42,144 KB
testcase_04 WA -
testcase_05 AC 296 ms
42,080 KB
testcase_06 AC 296 ms
42,120 KB
testcase_07 AC 296 ms
42,156 KB
testcase_08 AC 295 ms
42,080 KB
testcase_09 AC 296 ms
42,072 KB
testcase_10 AC 295 ms
42,156 KB
testcase_11 AC 296 ms
42,076 KB
testcase_12 AC 296 ms
42,016 KB
testcase_13 AC 295 ms
42,072 KB
testcase_14 AC 297 ms
42,160 KB
testcase_15 AC 294 ms
42,060 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 295 ms
42,076 KB
testcase_19 WA -
testcase_20 AC 296 ms
42,228 KB
testcase_21 WA -
testcase_22 AC 295 ms
42,016 KB
testcase_23 AC 296 ms
42,088 KB
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){
		if (a == 0)return 1;
		if (b == 0)return 1;
		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;
			if (d == 1)break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}
0