CF_495A Digital counter

A. Digital Counter
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Malek lives in an apartment block with 100 floors numbered from 0 to 99. The apartment has an elevator with a digital counter showing the floor that the elevator is currently on. The elevator shows each digit of a number with 7 light sticks by turning them on or off. The picture below shows how the elevator shows each digit.

One day when Malek wanted to go from floor 88 to floor 0 using the elevator he noticed that the counter shows number 89 instead of88. Then when the elevator started moving the number on the counter changed to 87. After a little thinking Malek came to the conclusion that there is only one explanation for this: One of the sticks of the counter was broken. Later that day Malek was thinking about the broken stick and suddenly he came up with the following problem.

Suppose the digital counter is showing number n. Malek calls an integer x (0 ≤ x ≤ 99good if it's possible that the digital counter was supposed to show x but because of some(possibly none) broken sticks it's showing n instead. Malek wants to know number of good integers for a specific n. So you must write a program that calculates this number. Please note that the counter always shows two digits.

Input

The only line of input contains exactly two digits representing number n (0 ≤ n ≤ 99). Note that n may have a leading zero.

Output

In the only line of the output print the number of good integers.

Sample test(s)
input
89
output
2
input
00
output
4
input
73
output
15
Note

In the first sample the counter may be supposed to show 88 or 89.

In the second sample the good integers are 000880 and 88.

In the third sample the good integers are 03, 08, 09, 33, 38, 39, 73, 78, 79, 83, 88, 89, 93, 98, 99.


题意:
有一个两位数字钟,可能会有某些位上的二极管坏掉了,所以会出现不同数字的情况。给你一个显示的数字(可能是坏掉的情况),求所有可能的情况。
题解:
对于数字钟上的0~9的显示大家应该是清楚的。所以对应的数字的情况也就很容易找到。最直接的想法就是给每位编号。存储0101的信号来表示亮灭。依次遍历,统计可能的情况,注意当此时数字显示(1)的,其余可能情况的对应位也必须显示,其余随意。十位与个位分开计算,结果是乘积的关系。
代码实现:
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;


int digit1[7], digit2[7];//十位,个位
int a[10][7]={{1,1,1,1,1,1,0},{0,0,1,1,0,0,0}, {0,1,1,0,1,1,1},{0,1,1,1,1,0,1},{1,0,1,1,0,0,1},{1,1,0,1,1,0,1}
,{1,1,0,1,1,1,1},{0,1,1,1,0,0,0},{1,1,1,1,1,1,1},{1,1,1,1,1,0,1}};//初始化
int n;
int main()
{
    scanf("%d", &n);
    int m = n / 10;
    n = n % 10;
    int x=0,y=0;
    //统计十位
    for(int i = 0; i < 10; i++)
    {
        bool flag=true;
        for(int k=0;k<7;k++)
            digit1[k]=a[m][k];
        for(int j=0; j < 7; j++)
        {
            if(digit1[j]==1 && a[i][j] != 1)
            {
                flag=false;
                break;
            }
        }
        if(flag)
            x++;
    }
    //统计个位
    for(int i = 0; i < 10; i++)
    {
        bool flag=true;
        for(int k=0;k<7;k++)
            digit2[k]=a[n][k];
        for(int j=0; j < 7; j++)
        {
            if(digit2[j]==1 && a[i][j] != 1)
            {
                flag=false;
                break;
            }
        }
        if(flag)
            y++;
    }
    printf("%d\n", x*y );
    return 0;
}

额。。。。脑子直是耽误事儿。。其实直接数也行对吧?。。但是我还是坚持认为我这种方法是有优势存在的!!具体在哪儿还得有时间来证明。。。
附上另一个版本:

         
         
int a[10] = {2, 7, 2, 3, 3 ,4, 2, 5, 1, 2}, n; int main() {     scanf("%d", &n);     printf("%d\n", a[n / 10] * a[n % 10]);     return 0; }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值