Given a number of 0-9 each. You can arrange these numbers in any order, but you must use them all. The goal is to make the last available number as small as possible (note that 0 cannot do the first). For example: Given two x 0, two 1, three 5, and one 8, the smallest number we get is 10015558.
Now given the number, write the minimum number that the program output can consist of.
Input format:
Each input consists of 1 test cases. Each test case gives 10 nonnegative integers in a row, which means we have the number 0, the number 1 、...... Number of digits 9. Separate integers with a single space. The total number of 10 digits does not exceed 50 and has at least 1 non-0 digits.
Output format:
Outputs the smallest number that can be composed in a row.
Input Sample:
2 2 0 0 0 3 0 0 1 0
Sample output:
10015558
1#include <stdio.h>2#include <stdlib.h>3#include <iostream>4#include <string.h>5#include <string>6#include <math.h>7#include <algorithm>8 using namespacestd;9 Ten intMain () { One inta[Ten]; A for(intI=0;i<Ten; i++) - { -scanf"%d",&a[i]); the } - for(intI=1;i<Ten; i++) - { - if(a[i]!=0){ +printf"%d", i); -a[i]--; + Break; A } at } - for(intI=0;i<Ten; i++) - { - while(a[i]!=0) - { -printf"%d", i); ina[i]--; - } to } + return 0; -}
B1023. Minimum number of groups (20)