周赛一 ACdream 1196 模拟题

来源:互联网 发布:网络电子游戏官网 编辑:程序博客网 时间:2024/04/30 14:14

One Day, KIDx developed a beautiful pagination for ACdream. Now, KIDx wants you to make another one.

The are n pages in total.
The current page is cur.
The max distance to current page you can display is d.

Here are some rules:

  • The cur page button is disabled.
  • If cur page is the first page, the button "<<" should be disabled.
  • If cur page is the last page, the button ">>" should be disabled.
  • If the button "x" is disabled, print "[x]"; else print "(x)".
  • You should not display the "..." button when there is no hidden page.

You can assume that the button "..." is always disabled.

Input

There are multiple cases. 
Ease case contains three integers n, cur, d. 
1 ≤ n ≤ 100.
1 ≤ cur ≤ n.
0 ≤ d ≤ n.

Output

For each test case, output one line containing "Case #x: " followed by the result of pagination.

Sample Input

10 5 210 1 2

Sample Output

Case #1: (<<)[...](3)(4)[5](6)(7)[...](>>)Case #2: [<<][1](2)(3)[...](>>)

Hint

Case 2: 


#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){int a,b,c,num=0;while(cin>>a>>b>>c){num++;printf("Case #%d: ",num);if(b+c<a&&b-c>1){cout<<"(<<)[...]";for(int i=b-c;i<=b+c;i++)if(i!=b)printf("(%d)",i);      else  printf("[%d]",i);cout<<"[...](>>)";}if(b+c<a&&b-c<=1){if(b==1)cout<<"[<<]";elsecout<<"(<<)";for(int i=b-c;i<=b+c;i++){    if(i<1)continue; if(i!=b)printf("(%d)",i);else  printf("[%d]",i);}  cout<<"[...](>>)";}if(b+c>=a&&b-c<=1){if(b==1)cout<<"[<<]";elsecout<<"(<<)";for(int i=b-c;i<=b+c;i++){ if(i>a)break;if(i<1)continue;if(i!=b)printf("(%d)",i);      else  printf("[%d]",i);}{  if(b==a)cout<<"[>>]";elsecout<<"(>>)";}}if(b+c>=a&&b-c>1){cout<<"(<<)[...]";for(int i=b-c;i<=b+c;i++){  if(i>a)break;if(i!=b)printf("(%d)",i); else  printf("[%d]",i);}if(b==a) cout<<"[>>]"; elsecout<<"(>>)";}cout<<endl;}}//只有b=1时才是第一页才用[<<]//同理b=a。。。。//几组数据//10 5 2//10 2 2//10 5 9//10 8 3





0 0