标签:mamicode ace int close oid turn while pre img
#include<bits/stdc++.h> using namespace std; #define int long long const int maxn = 110; int k, m; int a[maxn], v[maxn][maxn]; int ans; void dfs(int pos, int sum) { if(sum > m){ int num = 1; for(int i = pos; i <= k; i++) num *= (a[i] + 1); ans += num; return; } if(pos > k) return; for(int i = 1; i <= a[pos]; i++) dfs(pos + 1,sum + v[pos][i]); dfs(pos + 1,sum); } signed main() { //freopen("in", "r", stdin); ios::sync_with_stdio(0); while (cin >> k >> m) { for (int i = 1; i <= k; i++) { cin >> a[i]; for (int j = 1; j <= a[i]; j++) cin >> v[i][j]; } ans = 0; dfs(1, 0); cout << ans << endl; } return 0; }
标签:mamicode ace int close oid turn while pre img
原文地址:https://www.cnblogs.com/xcfxcf/p/12818388.html