//Answer on Question#44998 - Progamming - C++#include <iostream>using namespace std;int main() { int T; cin >> T; while (T-- > 0) { static const int MAX_N = 20; static const int MAX_X = 500; int N, X; cin >> N >> X; int C; for (int i = 0; i < N; ++i) { cin >> C; } long long d; // d is the number of possibilities to get j gredits using a subset only from the first i subjects d = 1; for (int i = 1; i < X + 1; ++i) { d = 0; } for (int i = 1; i < N + 1; ++i) { for (int j = 0; j < X + 1; ++j) { // d is the sum of possibilities when we take the i-th subject and don'ttake it d = d; // we can not take the i-th subject and the number of credits won't change if (j >= C) d += d; // we can take the i-th subject and from the number of required credits substract the number of credits of the i-th subject } } cout << d << endl; }}
Comments