|
||||||||||
PaginationTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 146 Accepted Submission(s): 19 Problem Description 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. Input 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". Output 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 "[]". Sample Input
Sample Output
Hint 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". Source | ||||||||||
|