305120: CF976A. Minimum Binary Number
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Minimum Binary Number
题意翻译
## 题目描述 给定一个二进制数(没有多余前导0),可以对这个二进制数执行两种操作: 1. 交换相邻数位的数字; 2. 用 1 代替 11(例如 110 变成 10)。 输出执行任意操作(或者不操作)后这些二进制数中最小的二进制数。 ## 输入格式 第一行,一个数 n,表示这个二进制数的长度; 第二行,一个二进制数 s。 ## 输出格式 执行任意操作后最小的二进制数; ## 样例解释 样例一解释:1001->1010->1100->100 样例二解释:不用操作题目描述
String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001". You are given a correct string $ s $ . You can perform two different operations on this string: 1. swap any pair of adjacent characters (for example, "101" ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF976A/5a518872d8942914aef6c33d251688a64a8d6d74.png) "110"); 2. replace "11" with "1" (for example, "110" ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF976A/5a518872d8942914aef6c33d251688a64a8d6d74.png) "10"). Let $ val(s) $ be such a number that $ s $ is its binary representation. Correct string $ a $ is less than some other correct string $ b $ iff $ val(a)<val(b) $ . Your task is to find the minimum correct string that you can obtain from the given one using the operations described above. You can use these operations any number of times in any order (or even use no operations at all).输入输出格式
输入格式
The first line contains integer number $ n $ ( $ 1<=n<=100 $ ) — the length of string $ s $ . The second line contains the string $ s $ consisting of characters "0" and "1". It is guaranteed that the string $ s $ is correct.
输出格式
Print one string — the minimum correct string that you can obtain from the given one.
输入输出样例
输入样例 #1
4
1001
输出样例 #1
100
输入样例 #2
1
1
输出样例 #2
1