# Codeforces Round #300 - Quasi Binary(贪心)

Quasi Binary
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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 

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
char str;
int main()
{
int max_cnt;
int first;
while(~scanf("%s",str)){
int len=strlen(str);
max_cnt=0;
for(int i=0;i<len;i++){
max_cnt=max(max_cnt,str[i]-'0');
}
printf("%d\n",max_cnt);
for(int i=0;i<max_cnt;i++){
first=0;
for(int j=0;j<len;j++){
if(!first){
if(str[j]!='0'){
printf("1");
str[j]--;
first=1;
}
}
else{
if(str[j]!='0'){
printf("1");
str[j]--;
}
else{
printf("0");
}
}
}
printf(" ");
}
puts("");
}
return 0;
}

09-10 69
09-21 232                                                                  09-13 118
05-04 808
08-09 149
11-10 3万+
08-09 66
04-25 415
06-20 850
06-15 316
09-12 374
09-19 167
04-28 1655
01-05 2万+
03-25 点击重新获取   扫码支付  余额充值