zoukankan      html  css  js  c++  java
  • codeforces 495A. Digital Counter 解题报告

    题目链接:http://codeforces.com/problemset/problem/495/A

      这个题目意思好绕好绕~~好绕~~~~~,昨天早上做得 virtual 看不懂,晚上继续看还是,差点就想求救 XX 兽了,最终还是打住,尽量不要依赖人嘛。今天终于想到了,大感动 ~_~ 

      理解能力有待提高。。。

          One of the sticks of the counter was broken    这句话有一点误导人的成分,我刚开始就以为只有一条 stick 坏了= =,再看这句 because of some(possibly none) broken sticks。这句才是真的!!!被骗了吧,呵呵。。。

      就是说,给出一个 n,求出所有的 x 。本来应该输出 x 的,但由于一些 stick 坏了(当然也可能没有坏,此时还是 x ),于是输出 了 n。那么就暗示了,n 是少了一些sticks的(或与 x 相等),而相对的,x 是比 n 多了一些sticks(或相等) 的 !

      这个时候就是要考细心和观察力了。留意那些呈现数字的 7 条 棍。

      n                                             x                                         tot

      0                0,  8              2

      1                0,  1,  3,  4,  7,  8,  9      7

      2                2,  8                2

      3                3,  8,  9             3

      4                4,  8,  9             3

      5                5,  6,  8,  9            4

      6                6,  8              2

      7                0,  3,  7,  8,  9         5

      8                8                 1

      9                8,  9              2

      于是就有代码中的 s 表了。最后就是根据两位数来组合答案(个位数的数目 * 十位数的数目)

      

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstdlib>
     4 using namespace std;
     5 
     6 const int s[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};
     7 
     8 int main()
     9 {
    10     char num[5];
    11     while (scanf("%s", num) != EOF)
    12     {
    13         int a = num[0] - '0';
    14         int b = num[1] - '0';
    15         printf("%d
    ", s[a] * s[b]);
    16     }
    17     return 0;
    18 }

      

  • 相关阅读:
    感性的记录一次生活
    CF 696 A Lorenzo Von Matterhorn(二叉树,map)
    UVA 673 Parentheses Balance(栈)
    POJ 1363 Rails(栈)
    HDU 1314 Numerically Speaking(大数加减乘除+另类二十六进制互相转换)
    UVA 540 Team Queue(模拟+队列)
    HDU 1276 士兵队列训练问题(模拟)
    CF 480 B Long Jumps (map标记)
    UVA 136 Ugly Numbers
    HDU 1027 Ignatius and the Princess II
  • 原文地址:https://www.cnblogs.com/windysai/p/4166027.html
Copyright © 2011-2022 走看看