周赛-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 博弈论:是二人或多人在平等的对局中各自利用对方的策略变换自己的对抗策 ...
随机推荐
- ADO.net 实体类 、数据访问类
程序分三层:界面层.业务逻辑层.数据访问层 比较规范的写程序方法,要把业务逻辑层和数据访问层分开,此时需要创建实体类和数据访问类 实体类: 例 using System; using System.C ...
- !! 浅谈Java学习方法和后期面试技巧
浅谈Java学习方法和后期面试技巧 昨天查看3303回复33 部落用户大酋长 下面简单列举一下大家学习java的一个系统知识点的一些介绍 一.java基础部分:java基础的时候,有些知识点是非常重要 ...
- 解决Android抽屉被击穿问题
1,创建一个抽屉DrawerLayout,在V4包下android.support.v4.widget.DrawerLayout,在要设置抽屉的布局中设置android:layout_gravity= ...
- 夺命雷公狗---DEDECMS----11dedecms字段标签
如果我们在开发的时候需要对获取的某个字段进行二次开发,我们可以对字段值调用某个函数来完成需求, 实例代码如下所示: <!DOCTYPE html> <html> <hea ...
- yii2多语言设置
yii2的多语言切换功能 1.页面添加语言切换按钮,如下图: 代码如下: <ul> <li> <a href="javascri ...
- mysql 优化之注意
1.如果你真的想把返回的数据行打乱了,你有N种方法可以达到这个目的.这样使用只让你的数据库的性能呈指数级的下降.这里的问题是:MySQL会不得不去执 行RAND()函数(很耗CPU时间),而且这是为了 ...
- syscolumns表中所有字段的意思
--syscolumns表中所有字段的意思 name sysname --列名或过程参数的名称. id int --该列所属的表对象 ID,或与该参数关联的存储过程 ID. xtype tinyint ...
- Android判断网络状态
package com.ch.services; import com.ch.utils.NetWorkUtils; import android.app.Service; import androi ...
- phabricator
(1)安装./bitnami-phabricator-20160523-0-linux-x64-installer.run (2)中文phabricator-zh_CN.tar解压缩到/opt/pha ...
- java总结第三次//类和对象2、3
四.类和对象2 主要内容:Java类的继承.方法的重写.覆盖.访问控制.super 关键字.多态性及其应用 1.继承 要求:Java只支持单继承,不允许多重继承 一个子类只能有一个父类 一个父类可以派 ...