結果

問題 No.503 配列コレクション
ユーザー sugim48sugim48
提出日時 2017-04-07 22:59:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,503 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 98,236 KB
実行使用メモリ 50,412 KB
最終ジャッジ日時 2023-09-23 02:29:26
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,256 KB
testcase_01 WA -
testcase_02 AC 49 ms
50,256 KB
testcase_03 AC 51 ms
50,192 KB
testcase_04 AC 51 ms
50,392 KB
testcase_05 AC 47 ms
50,256 KB
testcase_06 AC 46 ms
50,184 KB
testcase_07 AC 46 ms
50,268 KB
testcase_08 AC 49 ms
50,204 KB
testcase_09 AC 47 ms
50,292 KB
testcase_10 AC 46 ms
50,200 KB
testcase_11 AC 46 ms
50,392 KB
testcase_12 AC 51 ms
50,260 KB
testcase_13 AC 48 ms
50,264 KB
testcase_14 AC 48 ms
50,204 KB
testcase_15 AC 47 ms
50,316 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 47 ms
50,388 KB
testcase_19 AC 52 ms
50,252 KB
testcase_20 AC 47 ms
50,200 KB
testcase_21 AC 47 ms
50,212 KB
testcase_22 AC 48 ms
50,200 KB
testcase_23 AC 47 ms
50,196 KB
testcase_24 AC 47 ms
50,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vi;
struct edge { int v; ll w; };

ll _MOD = 1000000009;
double EPS = 1e-10;
ll INF = INT_MAX;

const int N = 2000000, MOD = 1e9+7;
ll inv[N + 1], f[N + 1], fi[N + 1];
 
ll C(int x, int y) {
	return f[x] * fi[y] % MOD * fi[x - y] % MOD;
}

ll H(int x, int y) {
	if (!y) return !x;
	return C(x + y - 1, y - 1);
}

int main() {
	inv[1] = 1;
	for (int i = 2; i <= N; i++)
		inv[i] = -MOD / i * inv[MOD % i] % MOD;
	f[0] = fi[0] = 1;
	for (int i = 1; i <= N; i++) {
		f[i] = f[i - 1] * i % MOD;
		fi[i] = fi[i - 1] * inv[i] % MOD;
	}
	int NN, K, D; cin >> NN >> K >> D;
	int n = NN % (K - 1);
	if (!n) n += K - 1;
	int M = (NN - n) / (K - 1);
	ll y = 1, ans = 0;
	rep(x, M + 1) {
		ans = (ans + y * n % MOD * H(M - x, n - 1)) % MOD;
		y = y * D % MOD;
	}
	cout << (ans + MOD) % MOD << endl;
}
0