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. 实现Linux下的ls -l命令

    基本实现了Linux下的ls -l命令,对于不同的文件显示不同的颜色和显示符号链接暂时没有实现: /************************************************** ...

  2. Fragment的使用简单介绍【Android】

    Fragment在实际项目开发中使用的越来越多,如今简介一下 布局文件: <LinearLayout xmlns:android="http://schemas.android.com ...

  3. Twenty Newsgroups Classification任务之二seq2sparse(3)

    接上篇,如果想对上篇的问题进行测试其实可以简单的编写下面的代码: package mahout.fansy.test.bayes.write; import java.io.IOException; ...

  4. android学习日记19--四大组件之Services(服务)

    一个Android应用主要由四个基本组件组成,Android四大基本组件分别是Activity,Content Provider内容提供者,Service服务,BroadcastReceiver广播接 ...

  5. EasyARM i.mx28学习笔记——开箱试用总结

    0 前言     本月初(2014年8月)购买了周立功的EasyARM开发板,主控为EasyARM i.mx287.出于下面几个理由购买了该开发板.     [1]主要原因,有人约我一起学习一起使用该 ...

  6. C++ typedef typename

    [cpp] view plaincopy template<typename T> class A { public: typedef T a_type; }; template<t ...

  7. IIS 之 HTTP错误信息提示

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

  8. 3D分析之3D要素工具箱(转)

    来自:http://blog.csdn.net/kikitamoon/article/details/8193764 整理有关 ArcGIS 10.1 3D分析工具箱中,3D Feature 工具箱中 ...

  9. ios存储 plist 偏好设置 自定义对象存储

    1,plist Plist注意:不能存储自定义对象 Plist:数组和字典,  如何判断一个对象能不能使用Plist,就看下有没有writeToFile 获取应用的文件夹(应用沙盒) NSString ...

  10. PHP Slim 框架初体验之无法访问控制器

    话不多说,先把报错贴出来: 刚开始用slim框架,在设置完自动加载文件和路由文件之后,我写了一个控制器: <?php use \Psr\Http\Message\ServerRequestInt ...