hdu 6168 Numbers
Numbers
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 514 Accepted Submission(s): 270
LsF wants to make some trouble. While zk is sleeping, Lsf mixed up sequence a and b with random order so that zk can't figure out which numbers were in a or b. "I'm angry!", says zk.
Can you help zk find out which n numbers were originally in a?
For each test case:
∙The first line is an integer m(0≤m≤125250), indicating the total length of a and b. It's guaranteed m can be formed as n(n+1)/2.
∙The second line contains m numbers, indicating the mixed sequence of a and b.
Each ai is in [1,10^9]
The first line is an integer n, indicating the length of sequence a;
The second line should contain n space-seprated integers a1,a2,...,an(a1≤a2≤...≤an). These are numbers in sequence a.
It's guaranteed that there is only one solution for each case.
#include<bits/stdc++.h>
using namespace std;
const int maxn = +;
map<int,int>mp;
int s[maxn];//记录a和b
int t[maxn];//存储a数组的结果 void init()
{
mp.clear();
memset(t,,sizeof(t));
} int main()
{
int n;
while(~scanf("%d",&n) )
{
init();
for(int i=;i<=n;i++)
scanf("%d",&s[i]);
sort(s+,s+n+);
int tot = ;
for(int i=;i<=n;i++)
{
if(tot + (tot-)*tot/ >= n)//总数够了 就不需要再选下去了
break;
int x= s[i];
if(mp[x]== || mp.count(x)==)//前面是这个数在mp中 且数值为1 另外一个是这个不在mp中
{
for(int j=;j<tot;j++)
{
mp[x+t[j]]++;//把新挑出来的数和之前的都相加
}
t[tot++] = x;//存储这个数
}
else
{
mp[x]--;//这个数之前出现过 所以不需要加了
}
}
cout<<tot<<endl;
for(int i=;i<tot;i++)
{
if(i)
cout<<" ";
cout<<t[i];
}
cout<<endl;
}
return ;
}
hdu 6168 Numbers的更多相关文章
- HDU 6168 - Numbers | 2017 ZJUT Multi-University Training 9
/* HDU 6168 - Numbers [ 思维 ] | 2017 ZJUT Multi-University Training 9 题意: .... 分析: 全放入multiset 从小到大,慢 ...
- 2017 ACM暑期多校联合训练 - Team 9 1008 HDU 6168 Numbers (模拟)
题目链接 Problem Description zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk gen ...
- HDU 5522 Numbers 暴力
Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5522 ...
- hdu 5585 Numbers
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5585 思路:对于2和5只须看最后一位数,对于三看所有位的数字之和就行 #include<stdi ...
- hdu 5585 Numbers【大数+同余定理】
Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- hdu 5181 numbers
http://acm.hdu.edu.cn/showproblem.php?pid=5181 题意: 有一个栈,其中有n个数1~n按顺序依次进入栈顶,在某个时刻弹出. 其中m个限制,形如数字A必须在数 ...
- HDU Humble Numbers
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...
- HDU——1058Humble Numbers(找规律)
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- hdu 5181 numbers——思路+区间DP
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5181 题解:https://www.cnblogs.com/Miracevin/p/10960717.ht ...
随机推荐
- mysql 开启profiling
mysql 开启profiling
- Dom最常用的API
document方法: getElementById(id) Node 返回指定结点的引用 getElementsByTagName(name) NodeList 返回文档中所有匹配的元素的集合 cr ...
- 网站用sqlite库,报attempt to write a readonly database,解决方法
将sqlite数据库文件,设置为users完全控制.重启网站即可!
- 配置tomcat通过客户端访问
1:在tomcat conf/tomcat-users.xml 文件里 配置用户名和密码,以及访问方式 For example, to add the manager-gui role to ...
- PHP 接收筛选项包含0的select下拉菜单的处理
这种情况下,PHP的判断方法如下: $where = "1=1"; if ($get['status'] !== '' && $get['status'] !== ...
- Spark性能优化(一)
前言 在大数据计算领域,Spark已经成为了越来越流行.越来越受欢迎的计算平台之一.Spark的功能涵盖了大数据领域的离线批处理.SQL类处理.流式/实时计算.机器学习.图计算等各种不同类型的计算操作 ...
- R之ddlpy函数学习[转载]
转自:https://www.cnblogs.com/aloiswei/p/6032513.html 1.函数 ddply(.data, .variables, .fun = NULL, ..., . ...
- 【Cocos2dx 3.3】图片裁剪
从一个图片集中裁剪出需要的图片时,采用的坐标是屏幕坐标系: 示例如下: 图片:res/Images/grossini_dance_atlas.png ,每个人物大小为85* ...
- selenium webdriver显示等待时间
当页面加载很慢时,推荐使用显示等待:等到需要操作的那个元素加载成功之后就直接操作这个元素,不需要等待其他元素的加载 WebDriverWait wait = new WebDriverWait(dri ...
- sublime text3搭建react native
Sublime Text 3 搭建React.js开发环境 Sublime有很强的自定义功能,插件库很庞大,针对新语言插件更新很快,配合使用可以快速搭建适配语言的开发环境. 1. babel-subl ...