#include <iostream>
using namespace std;
int coin[5], ans[5], n, m;
void dfs(int i, int sum){
if (sum == m){
cout << '(';
for (int j=0; j<n; j++){
if (j != 0){
cout << ',';
}
cout << ans[j];
}
cout << ')' << '\n';
return;
}
if (i==n-1 || sum>m){
return;
}
for (int k=0; k<=m/coin[i]; k++){
ans[i] = k;
dfs(i+1, sum+k*coin[i]);
}
}
int main(){
cin >> n;
for (int i=0; i<n; i++){
cin >> coin[i];
}
cin >> m;
dfs(0, 0);
return 0;
}
1.
cout << ans[j];
2.
if (i==n-1 || sum>m){
return;
}
1. 如果j超過i要輸出0(代表後面的幣值還沒用到)
2. i==n-1改成i==n