当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2996:Pagination

题目描述
Google is one of the most popular web search engines in the world. Many chinese like it very much and use it frequently. But recently, China Internet Illegal Information Reporting Centre(CIIRC) strongly criticized Google for "violating China's laws and regulations, contravening social morality and injuring public interest." At the same time, the Great Firewall blocked more and more world famous websites regardless of the complaints from internet users.

As worrying about that Google will also be blocked soon, you decide to eatablish your own web search engine named Googolplex((10)^(10^100)) and share it with other ACMers.

Unitl now the spider of your Googolplex has crawled so many web pages that the page will be too long to display all the search result in a single page. So it's time to develop the pagination function for Googolplex.

Pagination is used for displaying a limited number of results on search engine results pages. As many nicely designed websites, the format of page numbers of your pagination should follow the specification below:

1. As demonstrated in the picture, the format of the page numbers consists of 7 parts. They are, from left to right: first page, left ellipsis, previous mark, middle pages, next mark, right ellipsis, last page. The middle pages part contains the current page that the user is visiting now(it's "8" in the picutre). Please note that some of these parts will be hidden if the current page is some specific values.

2. For the first page part: It always displays "1". If the first page of middle pages part is equal to 1, this part should be hidden.

3. For the left ellipsis part: It always displays "...". If the first page of middle pages part is 2, or the first page part is hidden, this part should be hidden.

4. For the previous mark part: It always displays "<<". If the current page is 1, this part should be hidden.

5. For the middle pages part: It displays M numbers at most. If M is greater than T, the total number of pages, it displays T numbers. The position of the current page C should be M/2+1. So there are M/2 numbers before C and M-(M/2+1) after C. If the numbers before C is less than M/2, the middle pages part will shift to right to ensure there are M numbers displayed in total. If the numbers after C is less than M-(M/2+1), the middle pages part will shift to left to ensure there are M numbers displayed in total. Please refer to the sample for clarification.

6. For the next mark part: It always displays ">>". If the current page is equal to the last page, this part should be hidden.

7. For the right ellipsis part: It always displays "...". If the last page of middle pages part is one less than the total number of pages, or the last page part is hidden, this part should be hidden.

8. For the last page part: It always displays T, the total number of pages. If the last page of middle pages part is equal to T, this part should be hidden.

Given T, the total number of pages, M, the number of pages displayed in the middle pages part, and C, the current page that the user is visiting now, please write a program to generate the page numbers of pagination in the required format.
输入解释
The input file contains several test cases. Each test case has a line containing three integers T (1 <= T <= 10^9), M (1 <= M <= 50), C (1 <= C <= T).
Input is terminated by a line contains "0 0 0".
输出解释
For each test case print one line containing the page numbers of the pagination in the requried format. Each part of the pagination should be separated by a single blank. Current page C should be wrapped by "[]".
输入样例
10 3 5
8 4 8
0 0 0
输出样例
1 ... << 4 [5] 6 >> ... 10
1 ... << 5 6 7 [8]
提示
For the second test case "8 4 8". The current page is 8, originally the middle pages part should display "6 7 8 9". But there are only 8 
pages in total, so the middle pages part should shift one page to left, and display "5 6 7 8".
来自杭电HDUOJ的附加信息
Recommend chenrui

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2996

最后修改于 2020-10-25T22:59:01+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)