Skip to content

Instantly share code, notes, and snippets.

@igaryhe
Created May 13, 2015 16:00
Show Gist options
  • Save igaryhe/e25bd4d090b2e271b66c to your computer and use it in GitHub Desktop.
Save igaryhe/e25bd4d090b2e271b66c to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define MAXM 100
#define MAX 2000
#define MOD 1000000007
int main() {
int m, r, s;
int array[MAXM + 10];
scanf("%d %d %d", &m, &r, &s);
int a = (r + s)/2, b = (r - s)/2;
for (int i = 0; i < m; ++i) {
int in;
scanf("%d", &in);
array[i] = in;
}
long long dp[MAXM + 10][MAX + 10] = {0};
if (a != 0 && b != 0) dp[0][0] = 1;
for (int i = 0; i < m; ++i) {
for (long long j = m; j > 0; --j) {
for (int k = a; k >= 0; --k) {
if (k >= array[i]) {
dp[j][k] = (dp[j][k] + dp[j - 1][k - array[i]]) % MOD;
}
}
}
}
long long count = 0;
for (int j = 0; j <= m; ++j) {
count += (dp[j][a] * dp[j][b]) % MOD;
}
printf("%lld", count);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment