贪心_4

来源:互联网 发布:全球数据交换中心 编辑:程序博客网 时间:2024/05/17 23:03

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
91 1 1 1 1 1 1 1 1 
Input
32
Output
310 11 11 
tt注意点

1.最高位数就是n

2.利用string里某个值可作为int计算,==时用引号

3.flag可以作为起始标志

4.循环结构要清晰


#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<string>using namespace std;int main(){    string a;    while(cin>>a)    {     //   return 0;        int len=0;        for(int i=0;i<a.size();i++)            len=max(len,a[i]-'0');        cout<<len<<endl;       // return 0;        for(int j=0;j<len;j++)        {            int flag=0;            for(int k=0;k<a.size();k++)            {                if(!flag)                {                    if(a[k]=='0')                        continue;                    else                    {                        printf("1");                        a[k]--;                        flag=1;                    }                }                else                {                    if(a[k]=='0')  printf("0");                    else                    {                        printf("1");                        a[k]--;                    }                }            }            printf(" ");        }        printf("\n");    }    return 0;}


0 0