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

 

Input
9
Output
9
1 1 1 1 1 1 1 1 1
Input
32
Output
3
10 11 11

解题思路:题目大意:将一个数拆分成几个由1和0组成的数。输出数的个数以及各个拆分后的数。

当n小于9的时候,只能拆分成n个1;

当n大于9时,用一个数组将n的各个位数存起来,其中最大的那个数Max则为输出数的个数;

输出时,共有Max个循环对数组输出,当数组元素大于等于1时,输出1,同时元素值减一;当数组元素等于0时,输出0;

注意:当数组输出的第一个数为0时选择不输出。直到第一个数不为0时输出。

#include<iostream>
#include<stdio.h>
#include<cstring> using namespace std;
int c[];
int main()
{
string s;
cin>>s;
int sum; if(s.length()==){
printf("%d\n",s[]-'');
for(int i=;i<=s[]-'';i++)
{
if(i==) printf("");
else
printf("");
}
printf("\n");
} else
{
int k=s.length();
for(int i=;i<=s.length();i++)
c[i]=s[s.length()-i]-'';
int Max=;
for(int i=;i<=k;i++)
{
if(c[i]>Max) Max=c[i];
}
printf("%d\n",Max);
while(Max--)
{
int i;int j=;
for(i=k;i>=;i--)
{
//cout<<i<<"H"<<c[i]<<endl;
if(c[i]==&&j==) {continue;}
else
{
j++;
if(c[i]!=){printf("");c[i]=c[i]-;}
else printf("");
}
}
printf(" ");
}
printf("\n"); }
return ;
}

CodeForces 538B的更多相关文章

  1. Codeforces Round #300(Div. 2)-538A.str.substr 538B.不会 538C.不会 。。。

    A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. LVS+DR源码安装

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  2. 通过VMName获取VM IP

    PS3.0下通过测试,PS2.0下没有 networkAdapters 这个属性: $vmname = "22012r2" $v = get-vm |where {$_.name ...

  3. hdu 5461 Largest Point 暴力

    Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...

  4. careercup-C和C++ 13.9

    13.9 编写支持对齐分配的malloc和free函数,分配内存时,malloc函数返回的地址必须都能被2的n次方整除. 解法: 一般来说,使用malloc,我们控制不了分配的内存会在堆里哪个位置.我 ...

  5. 《RESTful Web Services》第四章 设计URI

    引言 URI是跨越Web的资源描述符,一个URI由以下内容组成——协议.主机.端口号.路径

  6. java_枚举类枚举值

    package ming; enum Gender{ MALE("男"),FEMALE("女"); //public static final Gender M ...

  7. 命令行一键清除IE记录

    清除Internet临时文件 RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 清除Cookies RunDll32.exe InetCpl.cpl, ...

  8. memcached client --ref

    Clients Client API's / libraries Updated Jul 14, 2012 by dorma...@rydia.net ref:https://code.google. ...

  9. Session Store

    Session Store Configuration Session Usage Flash Data Session Drivers Configuration Since HTTP driven ...

  10. IIS 之 HTTP错误信息提示

    一.HTTP返回码 [1]1xx - 信息提示 这些状态代码表示临时的响应.客户端在收到常规响应之前,应准备接收一个或多个 1xx 响应. a. 100 - 继续. b. 101 - 切换协议. [2 ...