-
Notifications
You must be signed in to change notification settings - Fork 12
/
1145-dice_II.cpp
76 lines (46 loc) · 1.28 KB
/
1145-dice_II.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
#include <bits/stdc++.h>
#define ll long long
#define MAX 100100
using namespace std;
ll arr[15030];
vector <pair <ll,ll> > v;
ll temp[15030];
ll mod = 1e8+7;
int main()
{
#ifndef ONLINE_JUDGE
freopen("/home/sameer/Documents/sameer/input.sam","r",stdin);
#endif
ios_base::sync_with_stdio(false);
ll i,j,k,n,m,t,cont,a,b,s;
cin >> t;
ll cases = t;
while(t--){
memset(arr,0,sizeof arr);
memset(temp,0,sizeof temp);
cin >> n >> k >> s;
for(i=1;i <=k;i++) {
arr[i] = 1;
}
for(i=1;i <=s;i++) {
temp[i] = temp[i-1] + arr[i];
temp[i] %= mod;
}
for(i=2;i <=n;i++){
for(j =1;j <= s;j++) {
if(j-k >=0)
arr[j] = ((temp[j-1] - temp[j-k-1])) %mod ;
else
arr[j] = ((temp[j-1] - temp[0])) % mod;
if(arr[j] < 0)
arr[j] += mod;
}
for(j=1;j <=s;j++) {
temp[j] = (temp[j-1] + arr[j]) % mod;
temp[j] %= mod;
}
}
cout << "Case " << cases-t << ": " << arr[s] << endl;
}
return 0;
}