-
Notifications
You must be signed in to change notification settings - Fork 3
/
scenes2.cpp
125 lines (114 loc) · 2.59 KB
/
scenes2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* @brief Kattis - Mountain Scenes
* @author Donald Dong (@donaldong)
* @date 04/20/2018
*
* + DP
*/
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define hmap unordered_map
#define hset unordered_set
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define putchar putchar_unlocked
#define rep(i, s, e) for (size_t i = s, fe__ = e; i < fe__; ++i)
inline void scan(int&);
inline void scan(ll&);
inline void print(uint);
inline void print(ull);
inline void print(string&);
ll MOD = 1e9 + 7;
ll poss(int amt, int wid, int hgt, vector<vector<ll>> &used){
if (wid == 0 || amt == 0) return 1;
if (used[amt][wid] != -1) return used[amt][wid];
ll count = 0;
for (int i = 0; i <= hgt && i <= amt; ++i) {
count += poss(amt - i, wid - 1, hgt, used);
count %= MOD;
}
used[amt][wid] = count;
return count;
}
int main() {
int amt, wid, hgt;
cin >> amt >> wid >> hgt;
vector<vector<ll>> used(amt + 1, vector<ll>(wid + 1, -1));
ll ans = poss(amt, wid, hgt, used) - min(amt/hgt, hgt) - 1;
if (ans < 0) ans += MOD;
cout << ans << endl;
return 0;
}
inline void scan(int &number) {
bool negative = false;
int c;
number = 0;
c = getchar();
if (c=='-') {
negative = true;
c = getchar();
}
for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48;
if (negative) number *= -1;
}
inline void scan(ll &number) {
bool negative = false;
int c;
number = 0;
c = getchar();
if (c=='-') {
negative = true;
c = getchar();
}
for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48;
if (negative) number *= -1;
}
inline void print(uint n) {
if (n == 0) {
putchar('0');
return;
}
char buf[11];
int i = 10;
while (n) {
buf[i--] = n % 10 + '0';
n /= 10;
}
while (i < 10) putchar(buf[++i]);
}
inline void print(ull n) {
if (n == 0) {
putchar('0');
return;
}
char buf[20];
int i = 19;
while (n) {
buf[i--] = n % 10 + '0';
n /= 10;
}
while (i < 19) putchar(buf[++i]);
}
inline void print(string &s) {
rep(i, 0, s.length()) putchar(s[i]);
}