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. 深入理解计算机系统 第二章 信息的表示和处理 part2

      上一周遗留问题的解决 问题:原码.反码.补码是只针对有符号数吗?无符号数有没有这三种编码方式? 得到的答案:对于无符号数,原码.反码和补码是一致的 进一步,由于有符号数是以补码的形式存储在计算机中 ...

  2. k8s部署高可用Ingress

    部署高可用Ingress 官网地址https://kubernetes.github.io/ingress-nginx/deploy/ 获取ingress的编排文件 wget https://raw. ...

  3. PHP Laravel5实现的RBAC权限管理操作示例

    根据不同的权限,在菜单栏显示不同的功能,只对菜单进行了限制,若对路由也进行限制,可以根据菜单的例子,请自行完善,开发.下面请认真学习一下laravel的RBAC设计 1.建表(用户表.角色表.权限表. ...

  4. java编程思想第四版第十章习题

    第一题 package net.mindview.innerclasses; public class Outer { class Inner { Inner(){ System.out.printl ...

  5. opencv 6 图像轮廓与图像分割修复 2 使用多边形将轮廓包围

    使用多边形将轮廓包围 返回外部矩阵边界(boundingRect()函数) 寻找最小包围矩形(minAreaRect()函数) 寻找最小包围圆形(minEnclosingCircle函数) 用椭圆拟合 ...

  6. Springboot 系列(十六)你真的了解 Swagger 文档吗?

    前言 目前来说,在 Java 领域使用 Springboot 构建微服务是比较流行的,在构建微服务时,我们大多数会选择暴漏一个 REST API 以供调用.又或者公司采用前后端分离的开发模式,让前端和 ...

  7. 【Luogu P2002&P2341】消息扩散/受欢迎的奶牛

    Luogu P2002 Luogu P2341 使用强连通分量算法缩点 第一题统计入度为0的个数强连通分量数. 第二题的答案为当且仅当仅有一个强连通分量的出度为0时该强连通分量的节点数,原因如下:若一 ...

  8. sublime插件开发教程2

    直接进入正题 先新建个chajian.py python写起 import sublime import sublime_plugin class ExampleCommand(sublime_plu ...

  9. 【笔记】vue+springboot前后端分离实现token登录验证和状态保存的简单实现方案

    简单实现 token可用于登录验证和权限管理. 大致步骤分为: 前端登录,post用户名和密码到后端. 后端验证用户名和密码,若通过,生成一个token返回给前端. 前端拿到token用vuex和lo ...

  10. day 37 CSS

    参考博客:https://www.cnblogs.com/majj/p/9021419.html 1.CSS的三种链接样式: 行内链接(优先级最高) 内接样式 外接样式 <html lang=& ...