zoukankan      html  css  js  c++  java
  • 模拟 ACdream 1196 KIDx's Pagination

    题目传送门

     1 /*
     2     简单模拟;考虑边界的情况输出的是不一样的,还有思维好,代码能短很多
     3 */
     4 #include <cstdio>
     5 #include <iostream>
     6 #include <algorithm>
     7 #include <string>
     8 #include <cstring>
     9 #include <map>
    10 #include <vector>
    11 using namespace std;
    12 
    13 const int MAXN = 1e4 + 10;
    14 const int INF = 0x3f3f3f3f;
    15 
    16 int main(void)        //ACdream 1196 KIDx's Pagination
    17 {
    18     //freopen ("A.in", "r", stdin);
    19 
    20     int n, cur, d;
    21     int a[110];
    22     int cas = 0;
    23     while (scanf ("%d%d%d", &n, &cur, &d) == 3)
    24     {
    25         printf ("Case #%d: ", ++cas);
    26         if (cur == 1)    printf ("[<<]");
    27         else    printf ("(<<)");
    28 
    29         if (cur - d > 1)    printf ("[...]");
    30         for (int i=max(cur-d, 1); i<cur; ++i)    printf ("(%d)", i);
    31         printf ("[%d]", cur);
    32         for (int i=cur+1; i<=min(cur+d, n); ++i)    printf ("(%d)", i);
    33         if (cur + d < n)    printf ("[...]");
    34 
    35         if (cur == n)    printf ("[>>]");
    36         else printf ("(>>)");
    37         puts ("");
    38     }
    39 
    40     return 0;
    41 }
    42 
    43 /*
    44 Case #1: (<<)[...](3)(4)[5](6)(7)[...](>>)
    45 Case #2: [<<][1](2)(3)[...](>>)
    46 */
    编译人生,运行世界!
  • 相关阅读:
    伪多项式时间 Pseudo-polynomial time
    Aho-Corasick算法
    写给十八岁以下的你
    网络流算法
    Java static关键字
    带有负权边的最短路径问题
    Miller_Rabin(米勒拉宾)素数测试
    关于同余与模运算的总结
    UVa1585
    UVa修改版02
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4415721.html
Copyright © 2011-2022 走看看