码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces 495A. Digital Counter 解题报告

时间:2014-12-15 23:32:00      阅读:349      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

题目链接: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\n", s[a] * s[b]);
16     }
17     return 0;
18 }

  

codeforces 495A. Digital Counter 解题报告

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/windysai/p/4166027.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!