voidimpl(){ int n, p, q; cin >> n >> p >> q; int m, c; cin >> m; for (int i = 1;i < n;i++) { cin >> c; m = std::min(m, c); } if (q + m < p) { cout << (q + m); } else { cout << p; } }
int u[20][20]; int cnt[20]; int ans, n, t, m; int v[20][20]; std::unordered_set<string> st; voiddfs(int curr){ if (curr == n + 1) { for (int i = 1; i <= t;i++) { if (!cnt[i]) { return; } } std::vector<string> lst; for (int i = 1;i <= t;i++) { string s; char buf[2] = {}; for (int j = 1;j <= n;j++) { if (u[i][j]) { buf[0] = (char) j; s.append(buf); } } lst.push_back(s); } std::sort(lst.begin(), lst.end()); string s; for (constauto & i : lst) { s.append(i); s.append("|"); } if (st.insert(s).second) { ans ++; } return; } for (int i = 1; i <= t;i++) { int flag = 1; // check conflict for (int j = 1;j <= n && flag;j++) { if (v[curr][j] && u[i][j]) { flag = 0; } } if (flag) { u[i][curr] = 1; cnt[i] ++; dfs(curr + 1); u[i][curr] = 0; cnt[i] --; } if (!cnt[i]) { break; } } } voidimpl(){ cin >> n >> t >> m; int a, b; for (int i = 0;i < m;i++) { cin >> a >> b; v[a][b] = v[b][a] = 1; } dfs(1); cout << ans; }
i64 quickPow(i64 base, i64 t){ if (t == 1) { return base; } base %= M; i64 res = quickPow(base, t / 2) % M; res = res * res % M; if (t & 1) { res = res * base % M; } return res; }
i64 inv(int v){ returnquickPow(v, M - 2); }
int n; int a[110]; constexprint mask = 0b11111111111; i64 st[110][4096];
voidimpl(){ cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } st[0][1] = 1; for (int i = 1; i <= n; i++) { i64 p = 1 * inv(a[i]); for (int j = 1; j <= std::min(a[i], 10); j++) { for (int s = 0; s <= mask; s++) { i64 v = st[i - 1][s] * p % M; int idx = (s | (s << j)) & mask; st[i][idx] += v; st[i][idx] %= M; } } if (a[i] > 10) { for (int s = 0; s <= mask; s++) { i64 v = (st[i - 1][s] * p % M) * (a[i] - 10) % M; st[i][s] += v; st[i][s] %= M; } } } i64 ans = 0; for (int i = 0;i <= mask;i++) { if (i & (1 << 10)) { ans += st[n][i]; ans %= M; } } cout << ans; }