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. 搞懂MySQL InnoDB B+树索引

    一.InnoDB索引 InnoDB支持以下几种索引: B+树索引 全文索引 哈希索引 本文将着重介绍B+树索引.其他两个全文索引和哈希索引只是做简单介绍一笔带过. 哈希索引是自适应的,也就是说这个不能 ...

  2. Java并发编程系列-AbstractQueuedSynchronizer

    原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/10566625.html 一.概述 AbstractQueuedSynchronizer简 ...

  3. Springboot 系列(十三)使用邮件服务

    在我们这个时代,邮件服务不管是对于工作上的交流,还是平时的各种邮件通知,都是一个十分重要的存在.Java 从很早时候就可以通过 Java mail 支持邮件服务.Spring 更是对 Java mai ...

  4. Mysql、SqlServer、Oracle三大数据库的区别

    一.MySQL 优点: 体积小.速度快.总体拥有成本低,开源: 支持多种操作系统: 是开源数据库,提供的接口支持多种语言连接操作 : MySQL的核心程序采用完全的多线程编程.线程是轻量级的进程,它可 ...

  5. webpack中使用DefinePlugin定义全局变量

    DefinePlugin可以在编译时期创建全局变量.DefinePlugin是webpack注入全局变量的插件,通常使用该插件来判别代码运行的环境变量.

  6. 5分钟入门LingaScript-尝鲜中文版TypeScript

    续前文转载: 中文輸進去,程式出得來,開發者發大財 -LingaScript:中文化TypeScript, 虽然其中例程使用了繁体中文语法, 但它同时也支持简体中文语法. 注: 此文中VS Code的 ...

  7. 每天五分钟-javascript数据类型

    javascript数据类型分为基本数据类型与复杂数据类型 基本数据类型包括:string,number,boolean,null,undefined,symbol(es6) 复杂数据类型包括:obj ...

  8. bcrypt 安装不成功解决办法

    同一个项目,公司和家里的 node.js 的版本不同,导致项目安装依赖包时 bcrypt 安装不成功. 家里的版本为:8.11.3 公司的版本为:10.14.2 在当前项目中执行完下面两个命令后,报错 ...

  9. SqlServer如何给表添加新的字段以及字段注释

    语法: USE 数据库名ALTER TABLE 表名 ADD 字段名  类型  默认值  是否为空;EXEC sp_addextendedproperty N'MS_Description', N'注 ...

  10. Vue.js01:跑马灯效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...