周赛-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 博弈论:是二人或多人在平等的对局中各自利用对方的策略变换自己的对抗策 ...
随机推荐
- 《30天自制操作系统》07_day_学习笔记
harib04a: P126 获取按键编码: 让程序在按下键盘的键之后,将键值编码显示出来 修改的是前面编写的鼠标按键的处理键盘中断的函数inthandler21() 这里笔者介绍了怎样把中断号 ...
- Lintcode: Minimum Subarray
Given an array of integers, find the subarray with smallest sum. Return the sum of the subarray. Hav ...
- php面向对象(OOP)编程完全教程
摘自:http://www.php-note.com/article/detail/41 面向对象编程(OOP)是我们编程的一项基本技能,PHP5对OOP提供了良好的支持.如何使用OOP的思想来进行P ...
- @Transactional
转载请标明出处:http://blog.csdn.net/cuker919/archive/2010/10/21/5957209.aspx Spring事务的传播行为 在service类前加上@Tra ...
- ArrayList和LinkedList的几种循环遍历方式及性能对比分析(转载)
原文地址: http://www.trinea.cn/android/arraylist-linkedlist-loop-performance/ 原文地址: http://www.trinea.cn ...
- hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...
- Excel 生成sql语句
CONCATENATE 拼接字符串 IF 不能跟 CONCATENATE 连用,所以可以通过建立新列去完成更高的需求 新建一列 cw=CONCATENATE("insert into biC ...
- ant的那些闹挺事
今日发现了一个问题,用ant+hudson去运行脚本代码时,突然ant报错: 即使我在ant的build文件中指定了basedir=“C:/Users/145064/.hudson/jobs/haix ...
- $.getJSON异步请求和同步请求
先说一下我遇到的问题吧,我之前的一个函数想调用上一个函数的返回值,但是它的返回值一直为空,后来翻了一些资料才明白是异步请求在作怪,不多说,看例子,这是我之前有返回值函数的代码: function ge ...
- mysql 导入大数据的秘籍
在使用这种方法前,你必须先建立一个数据库,这个数据库是你希望将sql文件导入的数据库.假如你创建的数据库为demo_data,数据库文件为demo.sql 并且该数据库文件位于你的D盘下,即该文件在 ...