結果

問題 No.1011 Infinite Stairs
ユーザー wonda_t_coffee
提出日時 2020-03-20 22:23:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 289 ms / 2,000 ms
コード長 2,229 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 108,804 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-17 11:51:58
合計ジャッジ時間 3,302 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>
#define fix(n) cout<<fixed<<setprecision(n)
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sort(a) sort((a).begin(), (a).end())
#define uniq(a) sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a) reverse((a).begin(), (a).end())
#define ctos(c) string(1, (c))
#define out(d) cout << (d)
#define outl(d) std::cout<<(d)<<"\n"
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define ceil(x, y) ((x + y - 1) / (y))
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void solve() {
int n, d, k; cin >> n >> d >> k;
const int MAX = 90305;
ll dp[MAX][2] = {{}};
dp[0][0] = 1;
rep(i, n) {
ll sum = 0, cnt = 0;
for (int j = 0; j <= k; j++) {
dp[j][1] = sum;
if (cnt + 1 > d) {
cnt--;
sum = (sum - dp[j - d][0]) % MOD;
if (sum < 0) sum += MOD;
}
cnt++;
sum = (sum + dp[j][0]) % MOD;
}
// for (int j = 0; j < MAX; j++)
// debug2(j, dp[j][1]);
// outl("------------");
rep(i, MAX) dp[i][0] = dp[i][1];
}
outl(dp[k][1]);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
srand((unsigned)time(NULL));
fix(12);
solve();
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0