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. jsom快速入门

    JSON JSON: JavaScript Object Notation(JavaScript 对象表示法) JSON 是存储和交换文本信息的语法,具有自我描述性.类似 XML, 但比 XML 更小 ...

  2. 使用Atlas进行元数据管理之容错和高可用

    1. 介绍 Apache Atlas使用各种系统并与之交互,为数据管理员提供元数据管理和数据血缘信息.通过适当地选择和配置这些依赖关系,可以使用Atlas实现高度的服务可用性.本文档介绍了Atlas中 ...

  3. [TCP/IP] 网络层-抓包分析IP数据包首部

    ip数据包的结构:首部+数据部分 1.版本(v4或者v6)+首部长度(固定的20字节,所以就没有)+区分服务优先级(我的例子是 assured forwarding 31 0x1a 26,保证转发) ...

  4. Java多线程知识整理

    多线程 1. 多线程基础 多线程状态转换图 普通方法介绍 yeild yeild,线程让步.是当前线程执行完后所有线程又统一回到同一起跑线.让自己或者其他线程运行,并不是单纯的让给其他线程. join ...

  5. 解决vue数据渲染过程中的闪动问题

    关键代码 主要解决vue双大括号{{}}在数据渲染和加载过程中的闪动问题,而影响客服体验. html代码: <span class="tableTitle selftab" ...

  6. 【代码笔记】Web-CSS-CSS Align

    一,效果图. 二,代码. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  7. Snapde电子表格编写Exprtk脚本进行数据运算

    Snapde,一个专门为编辑超大型数据量CSV文件而设计的单机版电子表格软件:它运行的速度非常快,反应非常灵敏. 一.打开文件:用Snapde打开需要运算的CSV文件 二.添加行列:在编辑菜单找到设置 ...

  8. node配置微信小程序解密消息以及推送消息

    上一篇文章介绍过 微信小程序配置消息推送,没有看过的可以先去查看一下,这里就直接去把那个客服消息接口去解密那个消息了. 在这里我选择的还是json格式的加密. 也就是给小程序客服消息发送的消息都会被微 ...

  9. rocketmq批量消息投递

    批量发送消息可提高传递小消息的性能.同时也需要满足以下特征 批量消息要求必要具有同一topic.相同消息配置 不支持延时消息 建议一个批量消息最好不要超过1MB大小 示例 小于1MB String t ...

  10. vue watch监听验证码时,axios延迟发送post请求。

    标题写的全面一些,方便其他人检索,我就是找了半天找不到资料,最后自己搞定了. 原理: 每次监听到输入值变化,就打一个时间戳,然后暂停2秒再去提交post验证. 但是每次提交前,判断一下之前打的时间戳和 ...