#abc247a. A - Move Right
A - Move Right
Score : points
问题描述
有 个正方形横向排列。
你得到一个长度为 的字符串 ,仅包含字符 0
和 1
。
若 中的第 个字符为 1
,则表示从左数第 个正方形中有人;
若 中的第 个字符为 0
,则表示从左数第 个正方形中无人。
现在,所有人将同时向右边相邻的正方形移动。经过这次移动,原本位于最右侧正方形的人会消失。
确定在移动后每个正方形中是否有人,并以与 相同格式的字符串形式打印出结果。(参见示例输入/输出以获得更清晰的理解。)
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are squares lined up horizontally.
You are given a string of length consisting of 0
and 1
.
If the -th character of is 1
, there is a person in the -th square from the left;
if the -th character of is 0
, there is no person in the -th square from the left.
Now, everyone will move to the next square to the right simultaneously. By this move, the person who was originally in the rightmost square will disappear.
Determine if there will be a person in each square after the move. Print the result as a string in the same format as . (See also Sample Input / Output for clarity.)
Constraints
- is a string of length consisting of
0
and1
.
Input
Input is given from Standard Input in the following format:
Output
Print a string of length such that the -th character is 1
if there will be a person in the -th square from the left after the move, and 0
otherwise.
Sample Input 1
1011
Sample Output 1
0101
After the move, the person who was originally in the -st square will move to the -nd square,
the person in the -rd square to the -th square,
and the person in the -th square will disappear.
Sample Input 2
0000
Sample Output 2
0000
Sample Input 3
1111
Sample Output 3
0111
update @ 2024/3/10 10:35:01