当前位置:网站首页>PAT Grade B-B1023 Minimum Number of Groups (20)
PAT Grade B-B1023 Minimum Number of Groups (20)
2022-08-06 22:32:00 【nekoha_dexter】
Given numbers 0-9 each.You can arrange these numbers in any order, but you must use them all.The goal is to make the resulting number as small as possible (note that 0 cannot be the first).For example: given two 0s, two 1s, three 5s, and an 8, the smallest number we can get is 10015558.
Given a number, please write a program to output the smallest number that can be formed.
input format:
The input gives 10 non-negative integers in one line, in the order that we have the number 0, the number 1, ... the number 9.Separate integers with a space.The total number of 10 numbers does not exceed 50, and there is at least 1 non-zero number.
Output format:
Print the smallest number that can be formed on one line.
Input sample:
2 2 0 0 0 3 0 0 1 0Example output:
10015558#includeusing namespace std;int table[10];int main(){int h = 0, t;for(int i = 0; i < 10; ++i){cin >> t;table[i] = t;//Record the smallest integer as the first numberif(i && t && !h) h = i;}cout << h;table[h]--;for(int i = 0; i < 10; ++i)if(table[i])//Output from small to large, output one number and then output the next onewhile(table[i]){cout << i;table[i]--;}return 0;} 边栏推荐
猜你喜欢
随机推荐
s905l3a series brush armbian to teach you to build your own blog from 0
From VLAN to IPVLAN: Talking about virtual network devices and their cloud-native applications
xp系统怎么升级win7系统版本
HCIP笔记(九)
【How to use Medooze to realize multi-party video conference】
积极防御体系进阶:《DevSecOps敏捷安全》
HCIP笔记(十四)
7月 致 -.-- -..- -
Django项目的创建、Admin后台系统以及数据库迁移
LeetCode - 112. 路径总和;113. 路径总和 II【进阶】
【面试】分布式系统幂等性与顺序性及分布式锁
微信小程序发布动态页面模板
Harvested the "Innovation Pioneer" of the first computing power conference, what trends did Jinan Supercomputing "Data Storage Cluster System" reveal?
罗技键盘怎么调灯光 罗技k845怎么切换灯光
切点表达式
The Node study notes
MMDtection3D
D. Number into Sequence【1300】
猿人学-第二题
TL431的参考电极与负极之间的相移






![[ 漏洞复现篇 ] OpenSSH 命令注入漏洞 (CVE-2020-15778)](/img/b4/c12c851d3bf8120cdd14d76b2fed1e.png)


