A combination lock

Time limit: - MS    Space limitations: - KB 
Benchmark description: 1s, 128m
Problem Description

What the boss has a peculiar combination lock.
Cipher lock has n number (from 0 to 9) in a row.
Cipher lock has two buttons:
each time the button number 1, n numbers will be incremented (9 plus 1 to 0)
each time the button 2, n cyclic shifted one digit to the right. That digital number i moved to position i + 1, n of the original number to the number of digital mobile position.

For example, digital code lock 5937, press the button No. 1, 6048 becomes a digital
press button 2, numeral 8604 becomes

What the boss is to unlock the lock code is the minimum number of bits n can be locked, you can calculate the password to unlock it?

Input Format

The first line, an integer n, the digit of the password
a second row, consisting of integers n-numeric string representing an initial digital lock

Output Format

Line, n digits represent unlock password

Sample input 1

3
957

Sample output 1

024  

Sample Description:
Press the button to give 1: 068
Press button No. 1 obtained: 179
Press button No. 1 obtained: 280
Press button No. 1 obtained: 391
Press button No. 1 obtained: 402
Press button No. 2 obtained: 240
Press No. 2 button to get: 024

024 is the smallest of the three-digit can be

Sample input 2

4
2014

Sample output 2

0142

Sample input 3

20
21347891785512126959

Sample output 3

00676714047689234623

prompt

1 ≤ n ≤ 1000

【analysis】
 
[Standard] Cheng
 

Guess you like

Origin www.cnblogs.com/Limbo-To-Heaven/p/11347330.html