#include <iostream> #include <vector> using namespace std;
int total = 0;
void greedy(int* arr, int n, int K, int S, int i, vector<int>& res) { if (i == n) { if (res.size() == K) { int sum = 0; for (int j = 0; j != K; j++) sum += res.at(j); if (sum == S) total++; } return; } greedy(arr, n, K, S, i + 1, res); res.push_back(arr[i]); greedy(arr, n, K, S, i + 1, res); res.pop_back(); }
int main() { int T; cin >> T; for (int i = 0; i < T; i++) { unsigned int n, K, S; cin >> n >> K >> S; int* arr = new int[n + 5]; for (int j = 0; j < n; j++) cin >> arr[j]; total = 0; vector<int> v; greedy(arr, n, K, S, 0, v); cout << total << endl; }
return 0; }
|