Strange Addition

CodeForces - 305A

Unfortunately, Vasya can only sum pairs of integers (ab), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4.

Vasya has a set of k distinct non-negative integers d1, d2, ..., dk.

Vasya wants to choose some integers from this set so that he could sum any two chosen numbers. What maximal number of integers can he choose in the required manner?

Input

The first input line contains integer k (1 ≤ k ≤ 100) — the number of integers.

The second line contains k distinct space-separated integers d1, d2, ..., dk (0 ≤ di ≤ 100).

Output

In the first line print a single integer n the maximum number of the chosen integers. In the second line print n distinct non-negative integers — the required integers.

If there are multiple solutions, print any of them. You can print the numbers in any order.

Examples

Input
4
100 10 1 0
Output
4
0 1 10 100
Input
3
2 70 3
Output
2
2 70 sol:我太菜了,只会分类讨论一大堆情况qaq,简直就是个智障
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
int n,a[N],Id[]={};
inline void put0(int n)
{
int i;
for(i=;i<=n;i++) W();
}
int main()
{
int i,j,ans=;
R(n);
for(i=;i<=n;i++)
{
R(a[i]);
if(a[i]==) ans++;//
else if(a[i]<) Id[]=i;//00x
else if(a[i]<)
{
if(a[i]%==) Id[]=i;//0x0
else Id[]=i; //0xx
}
else
{
if(a[i]%==) Id[]=i;//x00
else if(a[i]%==) Id[]=i; //xx0;
else if((a[i]-a[i]%)%==) Id[]=i; //x0x
else Id[]=i; //xxx
}
}
if(Id[])
{
if(Id[])
{
if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]); W(a[Id[]]); W(a[Id[]]);
}
else
{
Wl(ans+); put0(ans); W(a[Id[]]); W(a[Id[]]);
}
}
else
{
if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]); W(a[Id[]]);
}
else if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]); W(a[Id[]]);
}
else
{
Wl(ans+); put0(ans); W(a[Id[]]);
}
}
}
else if(Id[])
{
if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]); W(a[Id[]]);
}
else if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]); W(a[Id[]]);
}
else
{
Wl(ans+); put0(ans); W(a[Id[]]);
}
}
else if(Id[])
{
if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]); W(a[Id[]]);
}
else
{
Wl(ans+); put0(ans); W(a[Id[]]);
}
}
else if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]);
}
else if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]);
}
else if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]);
}
else if(Id[])
{
Wl(ans+); put0(ans); W(a[Id[]]);
}
else
{
Wl(ans); put0(ans);
}
return ;
}
/*
Input
4
100 10 1 0
Output
4
0 1 10 100 Input
3
2 70 3
Output
2
2 70
*/
 

codeforces305A的更多相关文章

随机推荐

  1. spring transaction源码分析--事务架构

    1. 引言  事务特性 事务是并发控制的单元,是用户定义的一个操作序列.这些操作要么都做,要么都不做,是一个不可分割的工作单位.通过事务将逻辑相关的一组操作绑定在一起,以便服务器 保持数据的完整性.事 ...

  2. 详解MySQL表空间以及ibdata1文件过大问题

    ibdata1文件过大 原因分析 ibdata1是一个用来构建innodb系统表空间的文件,关于系统表空间详细介绍参考MySQL官网文档 上面是一个数据库的ibdata1文件,达到了780多G,而且还 ...

  3. 你觉得 .NET 性能低,可能只是因为你的能力低

    by Conmajia 本文由以下大佬赞助 加入赞助者行列 {{ sponsor.name }} 感恩,你们的赞助让我在抓耳挠腮写文章时不至于断了香烟. var s = [{ name: '◎梦想起航 ...

  4. Springboot 系列(五)Spring Boot web 开发之静态资源和模版引擎

    前言 Spring Boot 天生的适合 web 应用开发,它可以快速的嵌入 Tomcat, Jetty 或 Netty 用于包含一个 HTTP 服务器.且开发十分简单,只需要引入 web 开发所需的 ...

  5. mysql判断条件不存在插入存在更新某字段

    insert into mst_sequence(seq_type, seq_desc, seq_date, seq_no, create_time) VALUES('CK', 'XXX', NOW( ...

  6. Uncaught ReferenceError: jQuery is not defined

    页面调试时,明明引入了JQ文件,却一直提示Uncaught ReferenceError: jQuery is not defined错误. 转自:http://blog.csdn.net/baicp ...

  7. 突破瓶颈,再出发 - PM过程能力成熟度5级

    尽管程度不同,但PM的每个级别都在践行过程改进,并在4级借助数据,达到了“登峰造极”的程度.随着量化与统计分析的深入,项目会被优化到极其稳定的状态,组织的过程改进也就此进入了平台期. 平台期可以被视为 ...

  8. Java中的Iterable与Iterator详解

    在Java中,我们可以对List集合进行如下几种方式的遍历: List<Integer> list = new ArrayList<>(); list.add(5); list ...

  9. mongodb复制+分片集原理

    ----------------------------------------复制集---------------------------------------- 一.复制集概述: Mongodb ...

  10. leetcode题解-122买卖股票的最佳时期

    题目 leetcode题解-122.买卖股票的最佳时机:https://www.yanbinghu.com/2019/03/14/30893.html 题目详情 给定一个数组,它的第 i 个元素是一支 ...