B1023. Minimum number of groups (20)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.