-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path441.cpp
68 lines (45 loc) · 831 Bytes
/
441.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
65
66
67
68
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#define MAXN 14
using namespace std;
int a[MAXN], sol[MAXN], n;
void dfs( int i, int total ) {
if ( total > 7 ) {
return;
}
if ( i == n+1 ) {
if ( total == 7 ) {
for ( int k = 1; k <= 6; ++k ) {
printf( "%d%c", sol[k], (k<6) ? ' ' : '\n' );
}
}
return;
}
if ( a[i] > sol[total-1] ) {
int tmp = sol[total];
sol[total] = a[i];
dfs( i + 1, total+1 );
sol[total] = tmp;
}
dfs( i + 1, total );
}
int main( ) {
//freopen("in.txt","r",stdin);
scanf( "%d", &n );
if ( n == 0 ) {
return 0;
}
while ( true ) {
for ( int i = 1; i <= n; ++i )
scanf( "%d", &a[i] );
dfs( 1, 1 );
scanf( "%d", &n );
if ( n == 0 ) {
break;
}
putchar( '\n' );
}
return 0;
}