Codeforces Round #283 (Div. 2)–B. Secret Combination_html/css_WEB-ITnose

B. Secret Combination

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.

立即学习“前端免费学习笔记(深入)”;

水题,把环展开成链,而且最多加9次,所以暴力就行

  1. #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;char str[3000];char ans[3000];int main(){int n;while (~scanf("%d", &n)){scanf("%s", str);for (int i = n; i i + n - j){flag = true;}else if (n - cnt == i + n - j){for (int k = j; k str[k]){flag = true;break;}else{break;}}}if (flag){cnt = 0;for (int k = i; k

登录后复制

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
编程技术

由12306出错想到的div垂直居中的问题_html/css_WEB-ITnose

2025-3-29 5:32:14

编程技术

帮忙看看怎么修改这个css代码_html/css_WEB-ITnose

2025-3-29 5:32:17

0 条回复 A文章作者 M管理员
欢迎您,新朋友,感谢参与互动!
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
私信列表
搜索