博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdoj - 1342 Lotto
阅读量:4596 次
发布时间:2019-06-09

本文共 2103 字,大约阅读时间需要 7 分钟。

Problem Description
In a Lotto I have ever played, one has 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 file 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. 
题目链接:
 
#include 
#include
#include
using namespace::std;int map[15];int a[15],k=0;void dfs(int n, int m){ if(n == 6) { for(int i= 0;i
= k) return ; a[n] = map[m]; dfs(n+1,m+1); //自底向上递归 dfs(n,m+1);}int main(){ int t = 0; while(scanf("%d",&k) && k != 0) { memset(map,0,sizeof(map)); memset(a,0,sizeof(a)); if(t != 0) printf("\n"); //最后的输出结果和输入 0 之间不能有空行 for(int i=0; i

转载于:https://www.cnblogs.com/hdyss/p/10809310.html

你可能感兴趣的文章
习题2-6排列(permutation)
查看>>
Mybatis基本配置(一)
查看>>
Android攻城狮布局动画
查看>>
正则表达式零宽断言详解(?=,?<=,?!,?<!)
查看>>
20145205 《Java程序设计》实验报告三:敏捷开发与XP实践
查看>>
利用Spring.NET实现WCF的AOP编程
查看>>
第三方,解决模型无法在获取网络数据之后传值问题
查看>>
对比 Git 与 SVN,这篇讲的很易懂
查看>>
【snmp】Linux开启snmp及查询
查看>>
CSU 1532: JuQueen(线段树)
查看>>
设定MyEclipse编辑代码区域文字的大小及非keyword的字体、字形和颜色
查看>>
LeetCode【6】. ZigZag Conversion --思路图解与java实现
查看>>
git 合并分支
查看>>
NSNotification与NSNotificationCenter
查看>>
qt 中文乱码 处理QByteArray类型里含中文的数据
查看>>
跨库事务一致性问题的解决方式(例)
查看>>
ios build时,Undefined symbols for architecture xxx问题的总结
查看>>
JavaScript对象
查看>>
IIS7(Windows7)下最简单最强安装多版本PHP支持环境
查看>>
关于Cocos2d-x发布游戏的时候遇到的问题和解决
查看>>