zk has n numbers a1,a2,...,ana1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a new number (ai+aj)(ai+aj). These new numbers could make up a new sequence b1,b2,...,bn(n−1)/2b1,b2,...,bn(n−1)/2. 

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?

Input

Multiple test cases(not exceed 10). 

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 aiai is in [1,10^9]

Output

For each test case, output two lines. 

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)a1,a2,...,an(a1≤a2≤...≤an). These are numbers in sequence a. 

It's guaranteed that there is only one solution for each case.

Sample Input

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

Sample Output

3
2 2 2
6
1 2 3 4 5 6

这个看代码吧。QAQ

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n,m;
vector <int> a,b,c,ans;
map <int,int> mmp;
int main()
{
while(~scanf("%d",&n))
{
a.clear();
b.clear();
c.clear();
ans.clear();
mmp.clear();
int temp;
for(int i=0;i<n;i++)
{
scanf("%d",&temp);
a.push_back(temp);
if(mmp[temp]==0) mmp[temp]=1;
else mmp[temp]++; }
sort(a.begin(),a.end());
ans.push_back(a[0]);
for(int i=1;i<n;i++)
{
if(mmp[a[i]]==0) continue;
for(int j=0;j<ans.size();j++)
{
mmp[ans[j]+a[i]]--;
}
ans.push_back(a[i]);
mmp[a[i]]--;
} printf("%d\n",ans.size());
vector <int> ::iterator it;
for(it=ans.begin();it!=ans.end();it++)
{
if(it==ans.begin()) cout<<*it;
else cout<<" "<<*it;
}
cout<<endl;
}
return 0;
}

(全国多校重现赛一) H Numbers的更多相关文章

  1. (全国多校重现赛一)D Dying light

    LsF is visiting a local amusement park with his friends, and a mirror room successfully attracts his ...

  2. (全国多校重现赛一)F-Senior Pan

    Senior Pan fails in his discrete math exam again. So he asks Master ZKC to give him graph theory pro ...

  3. (全国多校重现赛一) J-Two strings

    Giving two strings and you should judge if they are matched.  The first string contains lowercase le ...

  4. (全国多校重现赛一)E-FFF at Valentine

    At Valentine's eve, Shylock and Lucar were enjoying their time as any other couples. Suddenly, LSH, ...

  5. (全国多校重现赛一)B-Ch's gifts

    Mr. Cui is working off-campus and he misses his girl friend very much. After a whole night tossing a ...

  6. (全国多校重现赛一)A-Big Binary Tree

    You are given a complete binary tree with n nodes. The root node is numbered 1, and node x's father ...

  7. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/ ...

  8. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位dp)

    题目链接:https://ac.nowcoder.com/acm/contest/163/J 题目大意:给定一个数N,求区间[1,N]中满足可以整除它各个数位之和的数的个数.(1 ≤ N ≤ 1012 ...

  9. 长春理工大学第十四届程序设计竞赛(重现赛)H.Arithmetic Sequence

    题意: 数竞选手小r最喜欢做的题型是数列大题,并且每一道都能得到满分. 你可能不相信,但其实他发现了一个结论:只要是数列,无论是给了通项还是给了递推式,无论定义多复杂,都可以被搞成等差数列.这样,只要 ...

随机推荐

  1. 不需要spring管理,自己根据名字取到对应的bean

    package com.yiban.abc.util; import org.springframework.beans.BeansException; import org.springframew ...

  2. 什么情况用ArrayList or LinkedList呢?

    ArrayList 和 LinkedList 是 Java 集合框架中用来存储对象引用列表的两个类.ArrayList 和 LinkedList 都实现 List 接口.先对List做一个简单的了解: ...

  3. awk 实用案例介绍

    awk 简介 • awk是 3 个姓氏的首字母,代表该语言的 3 个作者 • awk的版本有很多,包括: 旧版 awk,新版 awk(nawk), GNUawk(gawk)等 • awk程序有 awk ...

  4. Feign 调用丢失Header的解决方案

    问题 在 Spring Cloud 中 微服务之间的调用会用到Feign,但是在默认情况下,Feign 调用远程服务存在Header请求头丢失问题. 解决方案 首先需要写一个 Feign请求拦截器,通 ...

  5. 使用Jquery获取指定属性的值

    使用Jquery获取指定属性的值 <input type="hidden" value="{$time}" name="time" i ...

  6. 通过myclipse建立一个简单的Hibernate项目(PS:在单元测试中实现数据的向表的插入)

    Hibernate的主要功能及用法: Ⅰ.Hibernate封装了JDBC,使Java程序员能够以面向对象的思想对数据库进行操作 Ⅱ.Hibernate可以应用于EJB的J2EE架构,完成数据的持久化 ...

  7. nyoj 58-最少步数 (BFS)

    58-最少步数 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:17 submit:22 题目描述: 这有一个迷宫,有0~8行和0~8列: 1,1,1 ...

  8. shell配置文件

    个人配置主要集中在-/.profile文件中 打开新的交互式shell时,配置文件的执行顺序是/etc/profile  /etc/bashrc  ~/.profile   最后是~/.bashrc ...

  9. .NET开发者的机遇与WebAssembly发展史(有彩蛋)

    一.唠唠WebAssembly的发展历程 目前有很多支持WebAssembly的项目,但发展最快的是Blazor,这是一个构建单页面的.NET技术,目前已经从Preview版本升级到了beta版本,微 ...

  10. beego框架学习--beego orm映射

    什么是ORM 即Object-Relationl Mapping,它的作用是在关系型数据库和对象之间作一个映射,这样,我们在具体的操作数据库的时候,就不需要再去和复杂的SQL语句打交道,只要像平时操作 ...