forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1089Lotto.cpp
More file actions
51 lines (46 loc) · 1.11 KB
/
Copy path1089Lotto.cpp
File metadata and controls
51 lines (46 loc) · 1.11 KB
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
//ZJU 1089 Lotto
//2003.08.14 BY ADAI
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
int k,i,j,t,NeedBlank=0,no;
while(cin>>k){
if(k==0) break;
int* num=new int[k];
for(i=0;i<k;i++) cin>>num[i];
if(NeedBlank==1){
cout<<endl;
}
else NeedBlank=1;
int* a=new int[k];
for(i=0;i<6;i++) a[i]=0;
for(;i<k;i++) a[i]=1;
no=6;
for(t=0;t<(long)(pow(2,k)-pow(2,k-6)-pow(2,6)+2);t++){
if(no==6){
i=0;
while(a[i]==1) i++;
cout<<num[i];
for(i++;i<k;i++){
if(a[i]==0) cout<<" "<<num[i];
}
cout<<endl;
}
for(j=k-1;j>=0;j--){
if(a[j]==1){
a[j]=0;
no++;
}
else{
a[j]=1;
no--;
break;
}
}
}
delete []num;
delete []a;
}
return 0;
}