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 ...
随机推荐
- Service 的 onStartCommand(Intent, int, int) 返回值
(1)START_NOT_STICKY If the system kills the service after onStartCommand() returns, do not recreate ...
- javaScript高级教程(十) iframe
1.iframe的基础,深入理解frame是何物,属性该如何设置. iframe即内联框架.不同于frame,frame与frameset综合使用,成为帧,框架集.frame已经不大使用了.说白了,f ...
- wordpress注册后重定向到自定义页面
wordpress注册后重定向到自定义页面怎么操作?将下面的代码添加到当前主题的 functions.php 文件中即可 add_filter( 'registration_redirect', 'w ...
- [py][mx]django课程模型
课程模型分析 分3个表 先设计课程表, 这是1 在设计lesson表,添加一个外键,course. 课程 1 course 章节 n lesson 视频 n video 资源 n coursereso ...
- Python3之socket编程
一.socket的定义 Socket是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口.在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协议族隐藏在Socket接口后 ...
- (转)Elasticsearch索引mapping的写入、查看与修改
mapping的写入与查看 首先创建一个索引: curl -XPOST "http://127.0.0.1:9200/productindex" {"acknowledg ...
- python图片处理(一)
python图片处理需要先在cmd里面安装Pillow pip install Pillow 一.图片的打开与显示 from PIL import Image img=Image.open('d:/d ...
- discuz模板引擎
discuz是采用“编译型的模板”,就是指采用普通网页文件保存,在文件中插入需要动态显示数据的仿php的代码,最后进行编译成真正的php的文件保存为模板缓存文件,这个转换的过程就称为编译.在用户浏览页 ...
- 如何在SQL Server查询语句(Select)中检索存储过程(Store Procedure)的结果集?
如何在SQL Server查询语句(Select)中检索存储过程(Store Procedure)的结果集?(2006-12-14 09:25:36) 与这个问题具有相同性质的其他描述还包括:如何 ...
- LibSVM源码剖析(java版)
之前学习了SVM的原理(见http://www.cnblogs.com/bentuwuying/p/6444249.html),以及SMO算法的理论基础(见http://www.cnblogs.com ...