B. Quasi Binary
A number is called quasibinary if it decimal representation contains only digits 0 or 1. For example, numbers 0, 1, 101, 110011-are quasibinary and Numbers 2,.
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 Q Uasibinary numbers.
The second line print K numbers-the elements of the sum. All these numbers should is quasibinary according to the definition above, their sum should equal n. Do not has the to print the leading zeroes in the numbers. The order of numbers doesn ' t matter. If There is multiple possible representations, you is allowed to print any of them.
Sample Test (s)
Input
9
Output
9
1 1 1 1 1 1 1 1 1
Input
32
Output
3
10 11 11
Good question, very good question ~
Test instructions is to select the smallest number of numbers in a number of only 01 to make up N. and output these numbers.
Conventional ideas are easy to see, not more than 1000000 of the 01 number is 64, a table is not able to live it? But the question is not whether it can constitute n, but rather the number of components that require the least amount of output. Looks like a backpack, but not very good back. Because you have to record the best intermediate distance.
But the problem is a good idea is to use 01, put n a good look, each bit as a number, then the largest number is the result. Knock good each one to take a 1, not enough is 0, then the composition of this res number is not exactly what is required. OK, the answer is Jiangzi.
In fact, I think the problem-solving report is best not attached. The result of the uniform accompanying code is that everyone is lazy.
But I'm still attached. (^o^)/~ haha
#include <functional>#include <cstdio>#include <cstring>#include <string>#include <cctype>#include <cstdlib>#include <ctime>#include <climits>#include <cmath>#include <iostream>#include <string>#include <vector>#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <deque>#include <algorithm>#define Read Freopen ("Q.in", "R", stdin)#define Write Freopen ("Q.out", "w", stdout)#define LL Long Long#define MAXN 1000005#define MOD 9999999999using namespace STD;inta[Ten];intCntvoidGetintN) {cnt=0; while(n) {a[cnt++]=n%Ten; N/=Ten; }}intMain () {intN while(~scanf("%d", &n)) {intI,j; Get (n);intres=0; for(i=0; i<cnt;i++) {Res=max (res,a[i]); }cout<<res<<endl; for(j=0; j<res;j++) {i=cnt-1; while(a[i]<=0) i--; for(; i>=0; i--) {if(a[i]>0)cout<<"1";Else cout<<"0";if(A[i]) a[i]--; }cout<<" "; }cout<<endl; }}
Codeforces Round #300 B