codeforces305A
Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), 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
4
100 10 1 0
4
0 1 10 100
3
2 70 3
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的更多相关文章
随机推荐
- Windows Server 2012 R2安装SqlServer 2016
1.系统安装 微软操作系统 Windows Server 2012 R2 官方原版镜像 Windows Server 2012 R2 是由微软公司(Microsoft)设计开发的新一代的服务器专属操作 ...
- 103 - kube-scheduler源码分析 - 调度算法-寻找predicates和priorities
scheduler的主要逻辑是predicate和priority,前者回答哪些节点可以运行pod的问题,后者回答哪个节点更合适运行pod的问题.今天我们的任务是:从主函数出发,寻找predicate ...
- js 实现 复制 功能 (zeroclipboard)
#复制功能因访问权限和安全问题, 被浏览器禁了# 我要实现的功能:点击复制按钮,复制浏览器的当前页面地址,加上用户选择的参数(用户查找过滤),直接将该链接发给别人,点击打开就是对应的查找结果而不是默认 ...
- 1.4部署到IIS「深入浅出ASP.NET Core系列」
希望给你3-5分钟的碎片化学习,可能是坐地铁.等公交,积少成多,水滴石穿,谢谢关注. 很多人第一次在IIS中部署Asp.Net Core App的人都会遇到问题,会发现原来的部署方式无法运行Asp.N ...
- postgresql如何让主键自增
法一: Sql代码 收藏代码 CREATE TABLE customers ( customerid SERIAL primary key , companyname character varyin ...
- PostgreSql的Explain命令详解
http://toplchx.iteye.com/blog/2091860 使用EXPLAIN PostgreSQL为每个收到的查询设计一个查询规划.选择正确的匹配查询结构和数据属性的规划对执行效率是 ...
- MySQL InnoDB 存储引擎探秘
在MySQL中InnoDB属于存储引擎层,并以插件的形式集成在数据库中.从MySQL5.5.8开始,InnoDB成为其默认的存储引擎.InnoDB存储引擎支持事务.其设计目标主要是面向OLTP的应用, ...
- 学习day01
1.web C/S:Client Server 客户端 服务器 QQ,... B/S:Browser Server 浏览器 服务器 PC机:Personal Computer 个人电脑 2.HTML ...
- Django 无名参数与有名参数
无名参数 配置 urls ,我们需要导入 url 模块,以()定义一个无名的变量 from django.contrib import admin from django.urls import pa ...
- 微信小程序开发基础
前言: 微信小程序开入入门,如果你有html+css+javascript的基础,那么你就很快地上手掌握的.下面提供微信小程序官方地址:https://developers.weixin.qq.com ...