enter:
The first row: the total number of queries t
The second line: the number of coins that can be exchanged in the first query; the corresponding currency value to be exchanged in the first query
Row 3: Array of denominations of coins available for redemption on the first query
The fourth row: the type of coins that can be exchanged in the second query; the corresponding currency value to be exchanged in the second query
Row 5: Array of denominations of coins available for redemption in the second query
Sixth line: ...
Seventh line: ......
output:
The first row: the total number of coin-mining schemes at the first query
The second row: the total number of coin pooling schemes in the second query
The third row:......
#include <iostream>
#include <vector>
using namespace std;
int CalcNum(const vector<int> &vc, int n, int k) {
if (n == 1) {
if (k % vc[0]) {
return 0;
}
else {
return 1;
}
}
if (k == 0) {
return 1;
}
else if (k < 0) {
return 0;
}
return CalcNum(vc, n - 1, k) + CalcNum(vc, n, k - vc[n - 1]);
}
int main() {
int t;
int n;
int k;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> n >> k;
vector<int> vc(n);
for (int j = 0; j < n; j++) {
cin >> vc[j];
}
int Num = CalcNum(vc, n, k);
cout << Num << '\n';
}
return 0;
}