Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- #include <ctype.h>
- int polje[21];
- int main()
- {
- int t, i, n, m, brn, rj, j, k, komb, sum;
- scanf ("%d", &t);
- for (i = 0; i < t; i++){
- brn = 0;
- rj = 0;
- scanf ("%d %d", &n, &m);
- for (j = 0; j < n; j++){
- scanf ("%d", &polje[brn]);
- if (polje[brn] <= m)
- brn++;
- }
- komb = pow (2, brn);
- for (j = 1; j < komb; j++){
- sum = 0;
- for (k = 0; k < brn; k++){
- if (j & 1 << k) sum += polje[k];
- }
- if (sum == m){
- rj = 1;
- break;
- }
- }
- if (rj == 0)
- printf ("No\n");
- else
- printf ("Yes\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment