A9453 | Pages
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
User ainta is making a web site. This time he is going to make a navigation of the pages. In his site, there are $n$ pages numbered by integers from $1$ to $n$ . Assume that somebody is on the $p$ -th page now. The navigation will look like this:
<< $p-k$ $p-k+1$ $...$ $p-1$ $(p)$ $p+1$ $...$ $p+k-1$ $p+k$ >>When someone clicks the button "<<" he is redirected to page $1$ , and when someone clicks the button ">>" he is redirected to page $n$ . Of course if someone clicks on a number, he is redirected to the corresponding page.
There are some conditions in the navigation:
- If page $1$ is in the navigation, the button "<<" must not be printed.
- If page $n$ is in the navigation, the button ">>" must not be printed.
- If the page number is smaller than $1$ or greater than $n$ , it must not be printed.
You can see some examples of the navigations. Make a program that prints the navigation.
<< $p-k$ $p-k+1$ $...$ $p-1$ $(p)$ $p+1$ $...$ $p+k-1$ $p+k$ >>When someone clicks the button "<<" he is redirected to page $1$ , and when someone clicks the button ">>" he is redirected to page $n$ . Of course if someone clicks on a number, he is redirected to the corresponding page.
There are some conditions in the navigation:
- If page $1$ is in the navigation, the button "<<" must not be printed.
- If page $n$ is in the navigation, the button ">>" must not be printed.
- If the page number is smaller than $1$ or greater than $n$ , it must not be printed.
You can see some examples of the navigations. Make a program that prints the navigation.
输入格式
The first and the only line contains three integers $n$ , $p$ , $k$ ( $3<=n<=100$ ; $1<=p<=n$ ; $1<=k<=n$ )
输出格式
Print the proper navigation. Follow the format of the output from the test samples.
输入输出样例
输入 #1
17 5 2
输出 #1
<< 3 4 (5) 6 7 >>
输入 #2
6 5 2
输出 #2
<< 3 4 (5) 6
输入 #3
6 1 2
输出 #3
(1) 2 3 >>
输入 #4
6 2 2
输出 #4
1 (2) 3 4 >>
输入 #5
9 6 3
输出 #5
<< 3 4 5 (6) 7 8 9
输入 #6
10 6 3
输出 #6
<< 3 4 5 (6) 7 8 9 >>
输入 #7
8 5 4
输出 #7
1 2 3 4 (5) 6 7 8
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted