-
Notifications
You must be signed in to change notification settings - Fork 2
/
10164.cpp
64 lines (57 loc) · 1.02 KB
/
10164.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<stdio.h>
#define MAXN 1026
int Dummy[MAXN];
int Num[2*MAXN];
int A[MAXN];
int Sum, N;
void Print(int k) {
int i, j;
j = A[0];
printf("%d",Num[j]);
for(i = 1; i<k; i++){
j = A[i];
printf(" %d",Num[j]);
}
printf("\n");
}
int ncr(int level, int index, int r,int n) {
if(level == r ) {
if(Sum % N == 0){
printf("Yes\n");
Print(r);
return 1;
}
return 0;
}
for(int i = index; i<=n; i++) {
A[level] = i;
Sum += Num[i];
if(ncr(level+1,i+1,r,n) == 1) return 1;
Sum -= Num[i];
}
return 0;
}
int main() {
int i, k;
while(scanf("%d",&N) == 1) {
if(!N) break;
Sum = 0;
k = 0;
for(i = 1; i<=2*N-1; i++) {
scanf("%d",&Num[i]);
if(Num[i] % N == 0 && k<N)
Dummy[k++] = Num[i];
}
if(k == N) {
printf("Yes\n");
printf("%d",Dummy[0]);
for(i = 1; i<N; i++)
printf(" %d",Dummy[i]);
printf("\n");
continue;
}
if(ncr(0,1,N,2*N-1) == 0)
printf("No\n");
}
return 0;
}