当前位置:网站首页>B1023 group minimum
B1023 group minimum
2022-07-27 05:20:00 【Ye Chen】
1023 Group a minimum number (20 branch )
Given number 0-9 There are several of them . You can arrange these numbers in any order , But all must be used . The goal is to make the final number as small as possible ( Be careful 0 Can't be the first ). for example : Given two 0, Two 1, Three 5, One 8, The smallest number we get is 10015558.
Now give the number , Please write a program to output the smallest number that can be composed .
Input format :
Enter... On one line 10 Nonnegative integers , Order means we have numbers 0、 Numbers 1、…… Numbers 9 The number of . Integers are separated by a space .10 The total number of numbers does not exceed 50, And at least have 1 A non 0 The number of .
Output format :
Output the smallest number that can be composed in one line .
sample input
2 2 0 0 0 3 0 0 1 0
sample output
10015558
Topic analysis :
- Record the number of occurrences
- Note that in addition to 0 Outside the smallest number as the first , And write down the times minus one
The code is as follows :
#include <bits/stdc++.h>
using namespace std;
int main(){
int a[10];
for(int i=0;i<10;i++){
cin>>a[i];
}
for(int i=1;i<10;i++){
if(a[i]!=0){
cout<<i;
a[i]--;
break;
}
}
for(int i=0;i<10;i++){
for(int j=0;j<a[i];j++){
cout<<i;
}
}
return 0;
}
边栏推荐
猜你喜欢

1、 MySQL Foundation

JVM Part 1: memory and garbage collection part 10 - runtime data area - direct memory

JVM上篇:内存与垃圾回收篇十二--StringTable

JVM Part 1: memory and garbage collection part 7 -- runtime data area heap

Why is count (*) slow

Installation and template setting of integrated development environment pychar

支付流程如何测试?

微淼联合创始人孙延芳:以合规为第一要义,做财商教育“正规军”

整合SSM

Typescript details
随机推荐
Use of collection framework
Differences among left join, inner join and right join
Deep Qt5 signal slot new syntax
ssm框架整合
B1028 人口普查
Tcp server是如何一个端口处理多个客户端连接的(一对一还是一对多)
Two dimensional array summation exercise
Quoted popular explanation
B1023 组个最小数
Event
Raspberry pie RTMP streaming local camera image
JVM Part 1: memory and garbage collection -- runtime data area 4 - program counter
DBUtils
2021 OWASP top 6-10 collection
Mysql表的约束
35. Scroll
MySQL storage engine and its differences
支付流程如何测试?
JVM Part 1: memory and garbage collection part 12 -- stringtable
牛客剑指offer--JZ12 矩阵中的路径