模拟 ACdream 1196 KIDx's Pagination

时间:2022-02-21 14:26:44

题目传送门

 /*
简单模拟;考虑边界的情况输出的是不一样的,还有思维好,代码能短很多
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f; int main(void) //ACdream 1196 KIDx's Pagination
{
//freopen ("A.in", "r", stdin); int n, cur, d;
int a[];
int cas = ;
while (scanf ("%d%d%d", &n, &cur, &d) == )
{
printf ("Case #%d: ", ++cas);
if (cur == ) printf ("[<<]");
else printf ("(<<)"); if (cur - d > ) printf ("[...]");
for (int i=max(cur-d, ); i<cur; ++i) printf ("(%d)", i);
printf ("[%d]", cur);
for (int i=cur+; i<=min(cur+d, n); ++i) printf ("(%d)", i);
if (cur + d < n) printf ("[...]"); if (cur == n) printf ("[>>]");
else printf ("(>>)");
puts ("");
} return ;
} /*
Case #1: (<<)[...](3)(4)[5](6)(7)[...](>>)
Case #2: [<<][1](2)(3)[...](>>)
*/