B. Quasi Binary

Time Limit: 1 Sec  Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/538/problem/B

Description

A number is called quasibinary if its decimal representation contains only digits 0 or 1. For example, numbers 0, 1, 101, 110011 — are quasibinary and numbers 2, 12, 900 are not.

You are given a positive integer n. Represent it as a sum of minimum number of quasibinary numbers.

Input

The first line contains a single integer n (1 ≤ n ≤ 106).

Output

In the first line print a single integer k — the minimum number of numbers in the representation of number n as a sum of quasibinary numbers.

In the second line print k numbers — the elements of the sum. All these numbers should be quasibinary according to the definition above, their sum should equal n. Do not have to print the leading zeroes in the numbers. The order of numbers doesn't matter. If there are multiple possible representations, you are allowed to print any of them.

Sample Input

9

Sample Output

9
1 1 1 1 1 1 1 1 1

HINT

题意

给你一个数n,然后让你找 一些01组成的数,让这些数的和为n,让找最少的数,并且输出这些数

题解:

啊,对于每一位,由于最多减1,所以最少一定是每一位的最大值,比如213,则必须3次,才能把个位变成0

有这个想法之后,就不难做了,我们直接减1就了,当为0 的时候,就不减了

注意前导0的问题

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
/* inline void P(int x)
{
Num=0;if(!x){putchar('0');puts("");return;}
while(x>0)CH[++Num]=x%10,x/=10;
while(Num)putchar(CH[Num--]+48);
puts("");
}
*/
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** int main()
{
string s;
cin>>s;
int len=;
for(int i=;i<s.size();i++)
len=max(len,s[i]-'');
cout<<len<<endl;
for(int i=;i<len;i++)
{
int flag=;
for(int j=;j<s.size();j++)
{
if(!flag)
{
if(s[j]=='')
continue;
else
{
cout<<"";
s[j]--;
flag=;
}
}
else
{
if(s[j]=='')
cout<<"";
else
{
cout<<"";
s[j]--;
}
} }
cout<<" ";
}
}

Codeforces Round #300 B. Quasi Binary 水题的更多相关文章

  1. Codeforces Round #300 A. Cutting Banner 水题

    A. Cutting Banner Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/pro ...

  2. Codeforces Round #300 D. Weird Chess 水题

    D. Weird Chess Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/proble ...

  3. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  4. Educational Codeforces Round 7 A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...

  5. Codeforces Round #336 (Div. 2)-608A.水题 608B.前缀和

    A题和B题...   A. Saitama Destroys Hotel time limit per test 1 second memory limit per test 256 megabyte ...

  6. Educational Codeforces Round 11 A. Co-prime Array 水题

    A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an ...

  7. Educational Codeforces Round 10 C. Foe Pairs 水题

    C. Foe Pairs 题目连接: http://www.codeforces.com/contest/652/problem/C Description You are given a permu ...

  8. A. Yellow Cards ( Codeforces Round #585 (Div. 2) 思维水题

    ---恢复内容开始--- output standard output The final match of the Berland Football Cup has been held recent ...

  9. Codeforces Round #345(Div. 2)-651A.水题 651B.。。。 651C.去重操作 真是让人头大

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

随机推荐

  1. Linux实用命令之git-svn

    近日发现了有一个工具,git-svn,可以打通git svn之间的鸿沟. 很适合习惯于git,却需要维护svn代码的同学. 安装 sudo apt-get install git-svn 具体使用就不 ...

  2. Linux系统调优及安全设置

    1.关闭SELinux #临时关闭 setenforce 0 #永久关闭 vim /etc/selinux/config SELINUX=disabled 2.设定运行级别为3 #设定运行级别 vim ...

  3. Geoserver WFS跨域设置

    测试版本为geoserver2.11.0. 两种方法都可以实现跨域设置: 第一种: 下载跨域jar包jetty-servlets.jar(下载geoserver使用的对应jetty版本——可以查看&l ...

  4. JSP基础与提高(一).md

    JSP基础 JSP的由来 1.1. 为什么有JSP规范 Servlet技术产生以后,在使用过程中存在一个很大的问题,即为了表现页面的效果而需要输出大量的HTML标签,这些标签在Servlet中表现为一 ...

  5. 数据分析python应用到的ggplot(二)

    还是优达学院的第七课 数据:https://s3.amazonaws.com/content.udacity-data.com/courses/ud359/hr_by_team_year_sf_la. ...

  6. 关于真多核和加多核&线程由哪几部分组成

    网上查的资料小结,没有考证. 真多核是指一个cpu多个核心,即多个内核. 假多核是指多个cpu捆绑形成的分布式计算,ARM针对服务器市场推出的处理器为多个cpu的 真多核的应用奔腾和因特尔 双核芯cp ...

  7. 使用Nginx代理Django

    一.准备环境 检查python版本以及pip版本 [root@linux-node01 src]# python --version Python 2.7.5 [root@linux-node01 s ...

  8. 洛谷 P1897电梯里的爱情 题解

    题目传送门 对于每个输入的第i个人,直接使用桶,但注意范围要开大一些. #include<bits/stdc++.h> using namespace std; ],x,sum,h,Max ...

  9. Jmeter----请求的reponse结果中的某个参数作为JDBC Request的查询条件

    一.前言 数据库连接成功,若不会的查看:https://www.cnblogs.com/syw20170419/p/9832402.html 二.需求 将登录账号12608523691,接口的repo ...

  10. 作死自救日记——不小心修改linux下/etc/sudoers权限的解决办法

    作死自救日记,献给跟我一样不小心作了死的人 ================================================ 今天不小心作死修改了/etc/sudoers的权限,作死命 ...