ACdream 1196 KIDx's Pagination(模拟)
2014-09-07 10:41
218 查看
KIDx's Pagination
Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others)SubmitStatisticNext
Problem
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.
![](http://acdream.info/img/prob/1196/3.jpg)
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:![](http://acdream.info/img/prob/1196/2.jpg)
Case 2:
![](http://acdream.info/img/prob/1196/1.jpg)
Source
KIDx
Manager
KIDxSubmitStatistic
感觉就是模拟电子书的页面显示效果
自己的代码写的比较挫...
代码如下:
#include <bits/stdc++.h> using namespace std; int main(void) { int n, cur, d, t; t = 1; while(scanf("%d%d%d", &n, &cur, &d) != EOF) { printf("Case #%d: ", t++); if(cur == 1 && cur == n) { printf("[<<][1][>>]\n"); continue; } if(cur == 1) { printf("[<<][1]"); if(cur+d < n) { for(int i=2; i<=cur+d; ++i) { printf("(%d)", i); } printf("[...](>>)\n"); } else if(cur+d >= n) { for(int i=2; i<=n; ++i) { printf("(%d)", i); } printf("(>>)\n"); } } else if(cur == n) { if(cur-d > 1) { printf("(<<)[...]"); for(int i=cur-d; i<n; ++i) { printf("(%d)", i); } } else if(cur-d <= 1){ printf("(<<)"); for(int i=1; i<n; ++i) { printf("(%d)", i); } } printf("[%d][>>]\n", n); } else if(cur-d > 1) { printf("(<<)[...]"); if(cur+d < n) { for(int i=cur-d; i<=cur+d; ++i) { if(i == cur) { printf("[%d]", i); } else printf("(%d)", i); } printf("[...](>>)\n"); } else if(cur+d >= n) { for(int i=cur-d; i<=n; ++i) { if(i == cur) printf("[%d]", i); else printf("(%d)", i); } printf("(>>)\n"); } } else if(cur-d <= 1){ printf("(<<)"); if(cur+d < n) { for(int i=1; i<=cur+d; ++i) if(i == cur) printf("[%d]", cur); else printf("(%d)", i); printf("[...](>>)\n"); } else if(cur+d >= n) { for(int i=1; i<=n; ++i) { if(i == cur) { printf("[%d]", i); } else printf("(%d)", i); } printf("(>>)\n"); } } } return 0; }
相关文章推荐
- 模拟 ACdream 1196 KIDx's Pagination
- ACdream 1196 KIDx's Pagination
- KIDx's Pagination (周赛1)
- A -KIDx's Pagination(练功底)
- KIDx's Pagination
- 周赛-KIDx's Pagination
- ACdream 1203 - KIDx's Triangle(解题报告)
- ACdream 1196 KIDx's Pagination(模拟)
- SGU 476 Coach's Trouble 大数模拟
- uva 10881 Piotr's Ants 模拟
- Uva 10881 Piotr's Ants (模拟+思维)
- Python _X __all__ 模拟 导入'私有'变量 及其注意点和实例
- acdream 1201 SuSu's Power dp
- ZOJ 3804 YY's Minions(简单模拟)
- As3模拟我的电脑,并实现'A'键后退,鼠标拖动文件夹
- ZOJ - 3804 YY's Minions(模拟)
- HDU 4706 Children's Day(模拟啊)
- 【ACDream】Andrew Stankevich's Contest (23)
- Codeforces 475C Kamal-ol-molk's Painting 模拟
- UVA 10817 - Headmaster's Headache(位运算模拟子集+dp)