Lotto
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6605   Accepted: 4185

Description

In the German Lotto you have to select 6 numbers from the set {1,2,...,49}. A popular strategy to play Lotto - although it doesn't increase your chance of winning - is to select a subset S containing k (k > 6) of these 49 numbers, and then play several games with choosing numbers only from S. For example, for k=8 and S = {1,2,3,5,8,13,21,34} there are 28 possible games: [1,2,3,5,8,13], [1,2,3,5,8,21], [1,2,3,5,8,34], [1,2,3,5,13,21], ... [3,5,8,13,21,34].

Your job is to write a program that reads in the number k and the set S and then prints all possible games choosing numbers only from S.

Input

The input will contain one or more test cases. Each test case consists of one line containing several integers separated from each other by spaces. The first integer on the line will be the number k (6 < k < 13). Then k integers, specifying the set S, will follow in ascending order. Input will be terminated by a value of zero (0) for k.

Output

For each test case, print all possible games, each game on one line. The numbers of each game have to be sorted in ascending order and separated from each other by exactly one space. The games themselves have to be sorted lexicographically, that means sorted by the lowest number first, then by the second lowest and so on, as demonstrated in the sample output below. The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.

Sample Input

7 1 2 3 4 5 6 7
8 1 2 3 5 8 13 21 34
0

Sample Output

1 2 3 4 5 6
1 2 3 4 5 7
1 2 3 4 6 7
1 2 3 5 6 7
1 2 4 5 6 7
1 3 4 5 6 7
2 3 4 5 6 7 1 2 3 5 8 13
1 2 3 5 8 21
1 2 3 5 8 34
1 2 3 5 13 21
1 2 3 5 13 34
1 2 3 5 21 34
1 2 3 8 13 21
1 2 3 8 13 34
1 2 3 8 21 34
1 2 3 13 21 34
1 2 5 8 13 21
1 2 5 8 13 34
1 2 5 8 21 34
1 2 5 13 21 34
1 2 8 13 21 34
1 3 5 8 13 21
1 3 5 8 13 34
1 3 5 8 21 34
1 3 5 13 21 34
1 3 8 13 21 34
1 5 8 13 21 34
2 3 5 8 13 21
2 3 5 8 13 34
2 3 5 8 21 34
2 3 5 13 21 34
2 3 8 13 21 34
2 5 8 13 21 34
3 5 8 13 21 34
 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[],b[],n; void dfs(int num,int p)
{
int i;
if(p>n)
return ;
if(num>=)
{
for(i=;i<;i++)
printf("%d ",b[i]);
printf("%d\n",b[]);
return ;
}
b[num]=a[p];
dfs(num+,p+);
dfs(num,p+);
return;
}
int main()
{
int i,flag=;
while(scanf("%d",&n),n)
{
if(flag)
printf("\n");
flag=;
for(i=;i<n;i++)
scanf("%d",&a[i]); dfs(,);
} }
												

Lotto--poj2245的更多相关文章

  1. POJ2245 Lotto

    Lotto Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6634   Accepted: 4201 Description ...

  2. poj 2245 Lotto

    Lotto Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6806   Accepted: 4298 Description ...

  3. ZOJ 1089 Lotto

    原题链接 题目大意:有一种抽奖游戏乐透(Lotto),规则是从1到49这49个自然数中随机抽取6个数.现在有一种简化版的游戏,先在49个数里面选出k(6<k<13)个数,然后再从这k个数里 ...

  4. hdoj 1342 Lotto【dfs】

    Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  5. Lotto(dfs)

    Lotto Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submis ...

  6. HDU1342 Lotto 【深搜】

    Lotto Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  7. Lotto

    Lotto Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submiss ...

  8. ZOJ2402 Lenny's Lucky Lotto List 简单DP

    Lenny's Lucky Lotto Lists Time Limit: 2 Seconds      Memory Limit:65536 KB Lenny likes to play the g ...

  9. 隐马尔科夫模型研究 stock 以及 lotto

    说明 本文参考了这里 由于数据是连续的,因此使用了高斯隐马尔科夫模型:gaussianHMM 一.stock代码 import tushare as ts import pandas as pd im ...

  10. ZOJ2402 Lenny's Lucky Lotto List 简单DP

    Lenny's Lucky Lotto Lists Time Limit: 2 Seconds      Memory Limit:65536 KB Lenny likes to play the g ...

随机推荐

  1. CentOS6.4x64安装mysql5.6.23(rpm)

    #查看已安装的的mysql shell>rpm -qa|grep -i mysql #根据上条命令的结果卸载mysql shell>rpm -e -nodeps mysql* #下载mys ...

  2. Effective Java单元测试TestNG - 就是爱Java

    TestNG是另一种单元测试的framework,与JUnit的类似,这次Mix将使用它来撰写测试程序,大部分所引用的class package都一样,只差在JUnit与TestNG的字样,可以直接用 ...

  3. 2015第10周五CSS—2

    经常遇到的浏览器兼容性有哪些?如何解决? 1.浏览器默认的margin和padding不同.解决方案是加一个全局的*{margin:0;padding:0;}来统一. 2.IE6双边距bug:块属性标 ...

  4. swing的第一课

    Swing介绍 Swing API 可扩展 GUI组件,以减轻开发者的生活创造基于JAVA前端/GUI应用.它是建立在AWT API之上,并作为 AWTAPI 的更换,因为它几乎每一个控制对应 AWT ...

  5. Jquery之家5个顶级Material Design框架

    谷歌Material Design在如今的前端页面设计中非常流行.Material Design的设计风格向我们展示了一个简单而有内涵的现代UI设计方案. Material Design是如此的简洁美 ...

  6. UESTC_邱老师选妹子(二) 2015 UESTC Training for Dynamic Programming<Problem I>

    I - 邱老师选妹子(二) Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Su ...

  7. OpenWrt for vmware 从openwrt.org下载10.03.1 或是自己下载最新的源码进行编译生成x86 vmdk格式

    1,直接从OpenWrt.org官网下载 http://downloads.openwrt.org/backfire/10.03.1/x86_generic/ 更新OpenWrt在线软件源 opkg ...

  8. linux 安装gcc和g++

    linux中安装gcc和g++ 今天在linux的服务器上安装C/C++的编译器gcc和g++,运行了如下两条命令: 1 yum install gcc yum install g++ 然后发现gcc ...

  9. JavaScript-打开新窗口

    open()方法可以查找一个已经存在或者新建一个新的浏览器窗口. 语法:window.open([URL], [窗口名称], [参数字符串]) 参数解释: URL:可选参数,在窗口中显示网页的网址或路 ...

  10. 解决红米等手机(移动端)无法触发touchend事件

    触屏事件的简单描述: js的触屏事件,主要有三个事件:touchstart,touchmove,touchend. 这三个事件最重要的属性是 pageX和 pageY,表示X坐标,Y坐标.touchs ...