KIDx's Pagination

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

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 2
10 1 2

Sample Output

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

Hint

Case 1:

Case 2:

周赛的一道模拟

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <algorithm>
#define LL long long
#define RR freopen("output.txt","r",stdin)
#define WW freopen("input.txt","w",stdout) using namespace std;
bool vis[120];
int main()
{
int n,cur,d;
int w=1;
while(~scanf("%d %d %d",&n,&cur,&d))
{
memset(vis,false,sizeof(vis));
for(int i=1; i<=n; i++)
{
if((cur-i<=d&&cur-i>=0)||(i-cur<=d&&i-cur>=0))
{
vis[i]=true;
}
}
printf("Case #%d: ",w++);
if(cur==1)
{
printf("[<<]");
}
else
{
printf("(<<)");
}
for(int i=1; i<=n; i++)
{
if(i==1)
{
if(vis[i])
{
if(cur==i)
printf("[%d]",i);
else
{
printf("(%d)",i);
}
}
else
{
printf("[...]");
}
}
else if(i==n)
{
if(vis[n])
{
if(cur==n)
printf("[%d]",i);
else
{
printf("(%d)",i); }
}
else
{
printf("[...]");
}
}
else if(vis[i])
{
if(cur==i)
printf("[%d]",i);
else
{
printf("(%d)",i);
} }
}
if(cur==n)
{
printf("[>>]");
}
else
{
printf("(>>)"); }
printf("\n");
} return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

周赛-KIDx's Pagination 分类: 比赛 2015-08-02 08:23 7人阅读 评论(0) 收藏的更多相关文章

  1. Rebuild my Ubuntu 分类: ubuntu shell 2014-11-08 18:23 193人阅读 评论(0) 收藏

    全盘格式化,重装了Ubuntu和Windows,记录一下重新配置Ubuntu过程. //build-essential sudo apt-get install build-essential sud ...

  2. iOS8 UISearchViewController搜索功能讲解 分类: ios技术 2015-07-14 10:23 76人阅读 评论(0) 收藏

    在iOS8以前我们实现搜索功能需要用到UISearchbar和UISearchDisplayController, 在iOS8之后呢, UISearchController配合UITableView的 ...

  3. iOS调用相机,相册,上传头像 分类: ios技术 2015-04-14 11:23 256人阅读 评论(0) 收藏

    一.新建工程 二.拖控件,创建映射 三.在.h中加入delegate @interface ViewController : UIViewController 复制代码 四.实现按钮事件 -(IBAc ...

  4. Hiking 分类: 比赛 HDU 函数 2015-08-09 21:24 3人阅读 评论(0) 收藏

    Hiking Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Subm ...

  5. Task schedule 分类: 比赛 HDU 查找 2015-08-08 16:00 2人阅读 评论(0) 收藏

    Task schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...

  6. LightOJ1002 分类: 比赛 最短路 2015-08-08 15:57 15人阅读 评论(0) 收藏

    I am going to my home. There are many cities and many bi-directional roads between them. The cities ...

  7. 山东理工大学第七届ACM校赛-学区房问题 分类: 比赛 2015-06-26 10:23 89人阅读 评论(0) 收藏

    Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 铁牌狗在学区B有一套面积为S1平方米的房子,现在他为了让后代进化成金牌狗,决定在学区A购 ...

  8. hadoop调优之一:概述 分类: A1_HADOOP B3_LINUX 2015-03-13 20:51 395人阅读 评论(0) 收藏

    hadoop集群性能低下的常见原因 (一)硬件环境 1.CPU/内存不足,或未充分利用 2.网络原因 3.磁盘原因 (二)map任务原因 1.输入文件中小文件过多,导致多次启动和停止JVM进程.可以设 ...

  9. 博弈论入门小结 分类: ACM TYPE 2014-08-31 10:15 73人阅读 评论(0) 收藏

    文章原地址:http://blog.csdn.net/zhangxiang0125/article/details/6174639 博弈论:是二人或多人在平等的对局中各自利用对方的策略变换自己的对抗策 ...

随机推荐

  1. sql server常见服务

    根据您决定安装的组件,SQL Server 安装程序将安装以下服务: SQL Server Database Services - 用于 SQL Server 关系数据库引擎的服务. 可执行文件为 & ...

  2. HTML中调用servlet的问题(?)

    最近在学习servlet.刚开始时,按照案例一行一行的敲代码.不过,出问题了. hello1.html <!DOCTYPE html> <html> <head> ...

  3. Linux 硬盘分区

    Linux系统中的重要概念,一切资源都看做是文件,包括硬件设备. 1. 基本概念 1)MBR:Master Boot Recorder,存放主引导记录,446字节的引导代码. 2)主分区表:存放主分区 ...

  4. MES: ESB

    ESB定义了消息的收发和收发池,对于各种通讯方式定义了收发API,在收到信息后由eventBus来发布消息 ISender: public abstract interface ISender { p ...

  5. SQL Server面试题

    前几天在博客园上看到一道SQL面试题,sc是表名.老师拿来与同学分享,让大家试做,要求是:查出每科成绩都>=80分的名字,看能写出几种方法.没有主外键,没有关联,脑袋一下子就蒙了.经老师讲解指导 ...

  6. JSP-07-使用JavaBean封装数据

    7.1 常命包名 Dao 包中的接口(NewsDao)以及类(NewsDaoImpl)注意负责和数据操作相关的事情. Service 包中的接口和类对dao的方法进行封装和调用,注意负责和业务逻辑相关 ...

  7. JSP-02- 使用JSP实现输出

    二. 使用JSP实现输出 JSP的页面构成: 静态内容.指令.表达式.Scriptlet.声明.动作.注释 Jsp脚本: 表达式.Scriptlet.声明 表达式: <%=  内容  %> ...

  8. linux中关于php和nginx用户权限的一些东西

    当我们启动nginx之后, 会有两个nginx进程(一个是master, 一个是worker). master的用户身份是root, worker用户的身份是nobody. 在nginx中可以修改 w ...

  9. 【转】“C语言说到底是一门以内存为中心的编程语言” —— 这种说法正确吗?

    转自:http://weibo.com/1005903613/AAgqA3kb4  LAW张粑粑的微博

  10. ASP.NET 中通过Form身份验证 来模拟Windows 域服务身份验证的方法

    This step-by-step article demonstrates how an ASP.NET   application can use Forms authentication to ...