当前位置:网站首页>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;
}
边栏推荐
- Event
- Could not autowire.No beans of ‘userMapper‘ type found.
- Li Kou achieved the second largest result
- 整合SSM
- 34. Analyze flexible.js
- Create datasource using Druid connection pool
- Laozi cloud and Fuxin Kunpeng achieved a major breakthrough in 3D ofd 3D format documents for the first time
- 节流函数的demo——正则表达式匹配
- 简化JDBC的MyBits框架
- Deep Qt5 signal slot new syntax
猜你喜欢

整合SSM

JDBC API 详解

Critical path principle

JVM上篇:内存与垃圾回收篇二--类加载子系统

来自“飞人”乔丹的启示!奥尼尔开启的另一个“赛场”

35. Scroll

Installation and template setting of integrated development environment pychar

Bean的生命周期&&依赖注入*依赖自动装配

34. 分析flexible.js

Select user stories | the false positive rate of hole state in jushuitan is almost 0. How to do this?
随机推荐
idea远程调试debug
牛客剑指offer--JZ12 矩阵中的路径
JVM上篇:内存与垃圾回收篇七--运行时数据区-堆
求组合数(最强优化)
Installation and template setting of integrated development environment pychar
JVM Part 1: memory and garbage collection part 8 - runtime data area - Method area
Counting Nodes in a Binary Search Tree
JVM Part 1: memory and garbage collection part 5 -- runtime data area virtual machine stack
Shell course summary
Acceptance and neglect of events
数据库设计——关系数据理论(超详细)
JVM Part 1: memory and garbage collection part 9 - runtime data area - object instantiation, memory layout and access location
数据库连接池&&Druid使用
35.滚动 scroll
2022年郑州轻工业新生赛题目-打死我也不说
34. Analyze flexible.js
Translation of robot and precise vehicle localization based on multi sensor fusion in diverse city scenes
How to sinicize the JMeter interface?
Acticiti中startProcessInstanceByKey方法在variable表中的如何存储
树莓派rtmp推流本地摄像头图像