周赛-KIDx's Pagination 分类: 比赛 2015-08-02 08:23 7人阅读 评论(0) 收藏
KIDx's Pagination
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
Ease case contains three integers n, cur, d.
1 ≤ n ≤ 100.
1 ≤ cur ≤ n.
0 ≤ d ≤ n.
Output
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) 收藏的更多相关文章
- Rebuild my Ubuntu                                                    分类:            ubuntu             shell             2014-11-08 18:23    193人阅读    评论(0)    收藏
		
全盘格式化,重装了Ubuntu和Windows,记录一下重新配置Ubuntu过程. //build-essential sudo apt-get install build-essential sud ...
 - iOS8 UISearchViewController搜索功能讲解                                                    分类:            ios技术             2015-07-14 10:23    76人阅读    评论(0)    收藏
		
在iOS8以前我们实现搜索功能需要用到UISearchbar和UISearchDisplayController, 在iOS8之后呢, UISearchController配合UITableView的 ...
 - iOS调用相机,相册,上传头像                                                    分类:            ios技术             2015-04-14 11:23    256人阅读    评论(0)    收藏
		
一.新建工程 二.拖控件,创建映射 三.在.h中加入delegate @interface ViewController : UIViewController 复制代码 四.实现按钮事件 -(IBAc ...
 - 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 ...
 - 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 ...
 - 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 ...
 - 山东理工大学第七届ACM校赛-学区房问题                                                       分类:            比赛             2015-06-26 10:23    89人阅读    评论(0)    收藏
		
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 铁牌狗在学区B有一套面积为S1平方米的房子,现在他为了让后代进化成金牌狗,决定在学区A购 ...
 - hadoop调优之一:概述                                                    分类:            A1_HADOOP             B3_LINUX             2015-03-13 20:51    395人阅读    评论(0)    收藏
		
hadoop集群性能低下的常见原因 (一)硬件环境 1.CPU/内存不足,或未充分利用 2.网络原因 3.磁盘原因 (二)map任务原因 1.输入文件中小文件过多,导致多次启动和停止JVM进程.可以设 ...
 - 博弈论入门小结                                                    分类:            ACM TYPE             2014-08-31 10:15    73人阅读    评论(0)    收藏
		
文章原地址:http://blog.csdn.net/zhangxiang0125/article/details/6174639 博弈论:是二人或多人在平等的对局中各自利用对方的策略变换自己的对抗策 ...
 
随机推荐
- 【转】Tomcat总体结构(Tomcat源代码阅读系列之二)
			
本文是Tomcat源代码阅读系列的第二篇文章,我们在本系列的第一篇文章:在IntelliJ IDEA 和 Eclipse运行tomcat 7源代码一文中介绍了如何在intelliJ IDEA 和 Ec ...
 - JS和JQUERY的区别
			
①.根据ID取元素 { JS:取到的是一个DOM对象. 例:var div = document.getElementByID("one"); JQUERY:取到的是一个JQUER ...
 - __int64和long long输入输出
			
__int64 num; scanf("%I64d", &num); printf("%I64d\n", num); long long num; sc ...
 - ruby初步学习中遇到的错误
			
print <<off This is the second way of creating here document ie. multiple line string; off 报错: ...
 - Multi-voltage和power gating的实现
			
power domain:一个逻辑的集合体,包含power supply的一些信息.建立在FE. voltage area:chip上的一块物理区域.可以看作power domain的物理实现. Le ...
 - ASP.NET MVC(二)
			
休息一下还是继续ASP.NET MVC 的基础知识. 这篇文件我想和大家一起熟悉下ASP.NET MVC项目的目录结构及dll. 1. ASP.NET MVC 项目的目录结构 App_Data: 存 ...
 - 让未激活的win8.1不再跳出提示激活的窗口
			
以管理员运行命令行: 输入以下命令: slmgr.vbs -upk
 - ILOG的一个基本应用——解决运输问题、转运问题
			
一.Ilog软件 该软件用来解决优化问题,大部分是线性问题,深一点的其他内容还不清楚.只知道一些基础的应用,网上相关内容很少.接下来就解决一个简单的运输问题 二.运输问题 数学模型 ILOG OPL程 ...
 - linux 安装
			
分区:/boot swap /这三个顺序分区 mkdir -p|-m cat >> 123.txt<<EOF 123 345 EOF 0.1和2分别表示标准输入.标准输出和标准 ...
 - redis make test报错 Test replication partial resync: ok psync
			
更改 tests/integration/replication-psync.tcl 文件: vi tests/integration/replication-psync.tcl 把对应报错的那段代码 ...