-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathF.cpp
More file actions
37 lines (33 loc) · 755 Bytes
/
Copy pathF.cpp
File metadata and controls
37 lines (33 loc) · 755 Bytes
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
#include<bits/stdc++.h>
using namespace std;
const int MAXN=510;
int N, M, B;
long long MOD = 999999999;
long long dp[MAXN][MAXN];
int main()
{
freopen("F.in","r",stdin);
freopen("F.out","w",stdout);
int tc;
cin>>tc;
while(tc--){
cin>>N>>M>>B;
for (int i=0;i<MAXN;i++)
for (int j=0;j<MAXN;j++)
dp[i][j]=0;
dp[0][0]=1;
for (int i=0;i<N;i++)
{
int a;cin>>a;
for (int j=0;j<M;j++)
for (int k=0;k<=B-a;k++)
if (dp[j][k])
dp[j+1][k+a]=(dp[j+1][k+a]+dp[j][k])%MOD;
}
long long ans=0;
for (int i=0;i<=B;i++)
ans=(ans+dp[M][i])%MOD;
cout <<ans<< "\n";
}
return 0;
}