Codeforces Round #283 (Div. 2)-B. Secret Combination (暴力)_html/css_WEB-ITnose
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
You got a box with a combination lock. The lock has a display showing n digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all digits 9 become digits 0), and the second button shifts all the digits on the display one position to the right (the last digit becomes the first one). For example, if the display is currently showing number 579, then if we push the first button, the display will show 680, and if after that we push the second button, the display will show 068.
You know that the lock will open if the display is showing the smallest possible number that can be obtained by pushing the buttons in some order. The leading zeros are ignored while comparing numbers. Now your task is to find the desired number.
Input
The first line contains a single integer n (1?≤?n?≤?1000) ? the number of digits on the display.
The second line contains n digits ? the initial state of the display.
Output
Print a single line containing n digits ? the desired state of the display containing the smallest possible number.
Sample test(s)
input
3579
output
024
input
42014
output
0142
题意:给一串数字,有两个操作,一个是add,可以使每个数字都加1,如果等于10,就变成0;另一个操作是每次让串里面的数字循环右移一位。问用这串数经过若此操作后,可以变成的最小串是多少。
分析:直接暴力搞起。add的变化范围只能是0~9(因为每10个一个循环),shift的范围在0~n。直接枚举即可。注意我们最开始挑选最小的时候,可以把“9......9",当做最大值~~~
AC代码:
#include#include #include #include #include #include #include #include
上一篇: jquery怎么去掉td里的内容
下一篇: php怎么去除空的数组元素
推荐阅读
-
Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)_html/css_WEB-ITnose
-
Codeforces Round #258 (Div. 2) B. Jzzhu and Sequences(矩阵快速幂)_html/css_WEB-ITnose
-
Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences_html/css_WEB-ITnose
-
Codeforces Round #280 (Div. 2)-B. Vanya and *s_html/css_WEB-ITnose
-
Codeforces Round #283 (Div. 2)--C. Removing Columns_html/css_WEB-ITnose
-
Codeforces Round #246 (Div. 2) ?B. Football Kit_html/css_WEB-ITnose
-
Codeforces Round #224 (Div. 2) D 暴力搜索加记忆化_html/css_WEB-ITnose
-
Codeforces Round #283 (Div. 2)--C. Removing Columns_html/css_WEB-ITnose
-
Codeforces Round #258 (Div. 2) B. Sort the Array_html/css_WEB-ITnose
-
Codeforces Round #277.5 (Div. 2)-B. BerSU Ball (贪心)_html/css_WEB-ITnose