题目描述

Your friend Superstitious Stanley is always getting himself into trouble. This time, in his Super Lotto Pick and Choose plan, he wants to get rich quick by choosing the right numbers to win the lottery. In this lottery, entries consist of six distinct integers from 1 to 49, which are written in increasing order. Stanley has compiled a list of winning entries from the last n days, and is going to use it to pick his winning numbers. 
In particular, Stanley will choose the six numbers that appeared the most often. When Stanley is breaking ties, he prefers smaller numbers, except that he prefers seven to every other number. What is Stanley’s entry?

输入

The first line of input contains a single integer T (1 ≤ T ≤ 100), the number of test cases. The first line of each test case contains a single integer n (1 ≤ n ≤ 1,000), the number of winning entries that Stanley compiled. The next n lines each contain a lottery entry as described above.

输出

For each test case, output a single line containing Stanley’s entry.

样例输入

复制样例数据

2
3
1 2 3 4 5 6
4 5 6 7 8 9
7 8 9 10 11 12
3
1 2 3 4 5 6
4 5 6 7 8 9
1 2 3 7 8 9

样例输出

4 5 6 7 8 9
1 2 3 4 5 7

提示

In the first test case, the numbers 4 through 9 appear twice each, while all other numbers appear at most
one time.
In the second test case, all numbers 1 through 9 appear twice each. The tiebreaking rule means Stanley
prioritizes picking 7 and then the five smallest numbers.

题目大意:

先输入一个整数t,代表下面有t组测试,对于每一组测试,先输入一个整数n,下面n行每行输入六个0到49的整数,计算每个整数出现的次数,找到出现次数最多的6个整数,按从小到大的顺序输出,且若7出现的次数与其他数字出现的次数相同,优先考虑7.

解题思路:

记录一下每一个数字出现的次数,将其存到一个结构体中,然后按照出现次数的大小对结构体进行排序,先将前5位存起来,若7已被存起,则继续存入第六位,若7没被存入,则比较7出现的次数与第六个元素出现的次数的大小,如果相等,则存入7,否则存入第六项。

代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
struct node
{int x;int num;
}arr[1200];
map<int,int> ma;
bool cmp(node a,node b) {if(a.num==b.num) return a.x<b.x;return a.num>b.num;
}
int arr1[10];
int main()
{#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endif//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);int t;cin>>t;while(t--) {int n;cin>>n;int nape,num7=0;ma.clear();int cnt=0;rep(i,1,n) {rep(j,1,6) {cin>>nape;if(nape==7) num7++;if(ma[nape]!=0) arr[ma[nape]].num++;else {cnt++;ma[nape]=cnt;arr[ma[nape]].x=nape;arr[ma[nape]].num=1;}}}sort(arr+1,arr+1+cnt,cmp);bool ju=false;rep(i,1,5) {arr1[i]=arr[i].x;if(arr[i].x==7) ju=true;}if(ju==false) {if(num7==arr[6].num) arr1[6]=7;else arr1[6]=arr[6].x;}else arr1[6]=arr[6].x;sort(arr1+1,arr1+7);rep(i,1,6) cout<<arr1[i]<<" ";cout<<endl;}return 0;
}

【模拟】Ingenious Lottery Tickets相关推荐

  1. Ingenious Lottery Tickets 模拟

    题目描述 Your friend Superstitious Stanley is always getting himself into trouble. This time, in his Sup ...

  2. 彩票假设 (Lottery Ticket Hypothesis) 在CV、NLP和OOD领域的应用

    ©PaperWeekly 原创 · 作者 | 张一帆 学校 | 中科院自动化所博士生 研究方向 | 计算机视觉 本文用三篇论文稍微普及和解读一下最近 Lottery Ticket Hypothesis ...

  3. HDU 3105 Fred's Lotto Tickets(数学题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3105 Problem Description Fred likes to play the lotto ...

  4. 【今日CV 计算机视觉论文速览 第112期】Mon, 6 May 2019

    今日CS.CV 计算机视觉论文速览 Mon, 6 May 2019 Totally 31 papers ?上期速览✈更多精彩请移步主页 Interesting: ?HDR图像超分辨联合算法, 通过重建 ...

  5. ECCV2022论文列表(中英对照)

    Paper ID Paper Title 论文标题 8 Learning Uncoupled-Modulation CVAE for 3D Action-Conditioned Human Motio ...

  6. 「彩票假说」要修正?王言治团队:神经网络要「中奖」,秘密在于学习率!|ICML 2021...

     视学算法报道   作者:刘宁 编辑:好困 [新智元导读]「彩票假说」指出神经网络可能存在准确率和原始网络相近的子网络.然而,这种中奖特性在许多情况中很难被观测到.最近,王言治教团队发现并揭示了中奖特 ...

  7. 收藏 | 一文总结70篇论文,帮你透彻理解神经网络的剪枝算法

    来源:DeepHub IMBA本文约9500字,建议阅读10+分钟 本文为你详细介绍神经网络剪枝结构.剪枝标准和剪枝方法. 无论是在计算机视觉.自然语言处理还是图像生成方面,深度神经网络目前表现出来的 ...

  8. ICLR 2021投稿中值得一读的NLP相关论文

    我们从 ICLR 2021开放投稿的3000篇论文中,粗略筛选了近100篇与自然语言处理领域中也许值得一读的论文,供大家查阅. 理论.模型与经验性分析:38篇 问答与阅读理解:4篇 知识图谱:4篇 文 ...

  9. 四篇NeurIPS 2019论文,快手特效中的模型压缩了解一下

    在即将过去的 2019 年中,快手西雅图实验室在 ICLR.CVPR.AISTATS.ICML 和 NeurIPS 等顶会上发表了十多篇论文. 除了这些研究方面的成果,针对实际业务,西雅图实验室和快手 ...

最新文章

  1. 负载均衡集群LVS模式之DR模型
  2. 度量、符号、转换关系
  3. 04737 c++程序设计 第二章 课后程序设计题 第一题
  4. php集合与数组的区别,php数组和链表的区别总结
  5. 基金理财系列6 之指数基金
  6. 一打开excel表,总提示有4.0版的宏
  7. fstream的使用(一)
  8. iOS开发之UILabel的使用
  9. 介绍计算机课程英语作文,关于电脑课的英语作文
  10. 好用的数据建模工具,探索中完善
  11. windows10系统下以管理员身份进入CMD(命令提示符)的三种方法
  12. 和我一起打造个简单搜索之Logstash实时同步建立索引
  13. 【CVPR华为】【CVPR诺亚方舟】【CVPR2019】华为诺亚方舟实验室2019年CVPR27篇:全面展现诺亚实验室在计算机视觉蓝图
  14. 我迟早被这些AI绘画笑死...
  15. 基于SSM框架的毕业设计管理系统 毕业设计-附源码211633
  16. HTML名人名言案例
  17. 画一只会动的皮卡丘(上)
  18. 水果店开业活动策划,水果店开业怎么搞活动
  19. U-Boot参数设置
  20. IPv4地址不够怎么解决

热门文章

  1. qt中使窗口的大小随窗口的内容大小进行调整
  2. Python divmod 函数 - Python零基础入门教程
  3. 云测试软件详解,软件测试之登录测试详解
  4. android+使用bmob冲突,bmob开发android遇到的问题
  5. linux操作系统字段含义,Linux系统 /etc/fstab各个字段含义解释
  6. linux 如何产生so文件,printf()函数 【转】Linux下gcc编译生成动态链接库*.so文件并调用它(2)...
  7. 简述python执行原理_Python程序的执行原理(1)(2)
  8. Java输出小明算对多少题目_2014年Java方向C组第十题
  9. pg数据库开启远程连接_疫情之下,开启在家办公模式,远程连接工具篇之向日葵...
  10. json符号解释大全_牛年汪姓男孩高端大气的名字大全