結果

問題 No.1011 Infinite Stairs
ユーザー misora192misora192
提出日時 2020-04-29 12:21:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 1,562 ms
コンパイル使用メモリ 164,912 KB
実行使用メモリ 4,980 KB
最終ジャッジ日時 2023-09-24 11:13:13
合計ジャッジ時間 3,388 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 83 ms
4,380 KB
testcase_04 AC 125 ms
4,980 KB
testcase_05 AC 125 ms
4,788 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 16 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 52 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 28 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 18 ms
4,380 KB
testcase_16 AC 86 ms
4,384 KB
testcase_17 AC 93 ms
4,528 KB
testcase_18 AC 38 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 21 ms
4,380 KB
testcase_22 AC 78 ms
4,452 KB
testcase_23 AC 20 ms
4,376 KB
testcase_24 AC 19 ms
4,376 KB
testcase_25 AC 37 ms
4,376 KB
testcase_26 AC 10 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n, d, k;
	cin >> n >> d >> k;

	ll max_n = n * (d - 1) + 1;
	
	ll dp[2][max_n];
	rep(i, 2) rep(j, max_n) dp[i][j] = 0;

	dp[0][0] = 1;
	rep(i, n){
		ll t = 0;
		rep(j, (i+1) * (d - 1) + 1){
			t += dp[i%2][j];
			t %= MOD;
			if(j >= d) {
				t += MOD - dp[i%2][j-d];
				t %= MOD;
			}
			dp[(i+1) % 2][j] = t;
		}
	}

	int idx = (k-1) - (n-1);
	if(idx < 0 || idx >= max_n){
		cout << 0 << endl;
	}else{
		cout << dp[n % 2][idx] << endl;
	}		
}
0