zoukankan      html  css  js  c++  java
  • 【HDOJ】2772 Matchsticks

    纯粹的找规律题。
    1: 2
    2: 5
    3: 5
    4: 4
    5: 5
    6: 6
    7: 3
    8: 7
    9: 6
    0: 6

    2     1     1
    3     7     7
    4     4    11
    5     2     71
    6     6     111
    7     8     711
    8     10     1111
    9     18     7111
    10     22    11111
    11     20    71111
    12     28    111111
    13     68    711111
    14     88
    15     108
    16     188
    17     200
    18     208
    19     288
    20     688
    21     888
    22     1088

     1 /* 2772 */
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <cstdlib>
     5 
     6 int a[15] = {0, 0, 1, 7, 4, 2, 6, 8, 10, 18, 22, 20, 28, 68, 88};
     7 int b[7] = {888, 108, 188, 200, 208, 288, 688};
     8 
     9 int main() {
    10     int t, n;
    11     int i, j, k;
    12     
    13     #ifndef ONLINE_JUDGE
    14         freopen("data.in", "r", stdin);
    15         freopen("data.out", "w", stdout);
    16     #endif
    17     
    18     scanf("%d", &t);
    19     while (t--) {
    20         scanf("%d", &n);
    21         // print min
    22         if (n < 15) {
    23             printf("%d", a[n]);
    24         } else {
    25             i = n % 7;
    26             printf("%d", b[i]);
    27             j = (n-15)/7;
    28             while (j--)
    29                 printf("8");
    30         }
    31         // print max
    32         i = n & 1;
    33         if (i == 0)
    34             printf(" 1");
    35         else
    36             printf(" 7");
    37         j = (n-2)/2;
    38         while (j--)
    39             printf("1");
    40         printf("
    ");
    41     }
    42     
    43     return 0;
    44 }
  • 相关阅读:
    Spring Bean的作用域类型
    spring depends-on
    spring bean parent属性详解
    spring中autowire的用法
    Spring容器的属性配置详解的六个专题
    Spring bean注入方式
    Spring入门示例
    如何从官网下载Spring
    Hibernate 缓存
    [转]javascript Date format(js日期格式化)
  • 原文地址:https://www.cnblogs.com/bombe1013/p/4183715.html
Copyright © 2011-2022 走看看