| 4 | long long N, S, A[61]; |
| 5 | |
| 6 | int main() { |
| 7 | cin >> N >> S; |
| 8 | for (int i = 1; i <= N; i++) cin >> A[i]; |
| 9 | |
| 10 | // 全パターンを探索:(1LL << N) は 2 の N 乗 |
| 11 | for (long long i = 0; i < (1LL << N); i++) { |
| 12 | long long sum = 0; |
| 13 | for (int j = 1; j <= N; j++) { |
| 14 | // (i & (1LL << (j-1))) != 0LL の場合、i の 2 進法表記の下から j 桁目が 1 |
| 15 | // (1LL << (j-1)) は C++ では「2 の j-1 乗」を意味します |
| 16 | if ((i & (1LL << (j-1))) != 0LL) sum += A[j]; |
| 17 | } |
| 18 | if (sum == S) { cout << "Yes" << endl; return 0; } |
| 19 | } |
| 20 | cout << "No" << endl; |
| 21 | return 0; |
| 22 | } |
nothing calls this directly
no outgoing calls
no test coverage detected