-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.c
51 lines (39 loc) · 999 Bytes
/
B.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h> // this is comment
long long int x;
int flag = 0;
void createArr(int i, int k, long long int b[k], int index, int n, long long int a[n]) {
if (flag == 0) {
if (index == n + 1);
else if (i == k) {
long long int sum = 0;
for (int j = 0; j < k - 1; j++) {
sum += b[j];
}
sum *= b[k - 1];
if (sum == x) {
flag = 1;
printf("Yes");
}
}
else {
createArr(i, k, b, index + 1, n, a);
b[i] = a[index];
createArr(i + 1, k, b, index + 1, n, a);
}
}
}
int main() {
int n, k;
scanf("%d %d %lld", &n, &k, &x);
long long int a[n];
long long int b[k];
for (int i = 0; i < n; i++) {
scanf("%lld ", a + i);
}
createArr(0, k, b, 0, n, a);
if (flag == 0) {
printf("No");
}
return 0;
}
// how to build a website using Github pages