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. 从PRISM开始学WPF(三)Prism-Region-更新至Prism7.1

    [7.1update]在开始前,我们先看下版本7.1中在本实例中的改动. 首先,项目文件中没有了Bootstrapper.cs,在上一篇的末尾,我们说过了,在7.1中,不见推荐使用Bootstrapp ...

  2. Springboot 系列(八)动态Banner与图片转字符图案的手动实现

    使用过 Springboot 的对上面这个图案肯定不会陌生,Springboot 启动的同时会打印上面的图案,并带有版本号.查看官方文档可以找到关于 banner 的描述 The banner tha ...

  3. myeclipse配置tomcat服务器

    在进行j2EE开发时,需要进行服务器配置, 这里因为要进行servlet开发,也要配置服务器.这里以在myeclipse上配置tomcat服务器为例 这里只是做下记录,方便自己以后查看 1.打开mye ...

  4. Springboot2注解使用Mybatis动态SQL

    1.简单SQL使用 //从***数据表获取统计数据 @Select("select count(*) from issues where issue_type = #{type}" ...

  5. Ext.isNumber与Ext.isNumeric

    Ext.isNumber: Ext.isNumber(1) true Ext.isNumber(new Number(1)) false Ext.isNumber("1") fal ...

  6. ES6系列之变量声明let const

    ES6也出来好久了,最近闲来无事就想着吧es6做一个系统的总结,巩固自己的知识,丰富一下博客. 为什么叫ES6 实际上是ECMA的一个打的标准,这个标准是在2015年6月发布的,正式的名字实际是es2 ...

  7. 《JavaScript高级程序设计》笔记:客户端检测(九)

    能力检测 在编写代码之前先检测特定浏览器的能力.例如,脚本在调用某个函数之前,可能要先检测该函数首付存在.这种检测方法将开发人员从考虑具体的浏览器类型和版本中解放出来,让他们把注意力集中到相应的能力是 ...

  8. 给萌新的Flexbox简易入门教程

    转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 原文出处:https://www.sitepoint.com/flexbox-css-flexible-bo ...

  9. Android远程桌面助手(B1371)

    Android远程桌面助手(B1371),下载:https://files.cnblogs.com/files/we-hjb/ARDC%28B1371%29.7z 1.增加了对超大分辨率4320*21 ...

  10. SQL 获取时间段内日期列表

    declare @start date,@end date; set @start='2010-01-01'; set @end='2010-02-01'; --获取时间段内日期列表 select [ ...