cf_495a Digital counter

Source: Internet
Author: User
Tags bool time limit
A. Digital Counter time limit per test 1 second memory limit per test megabytes input standard input output standard o Utput

Malek lives in a apartment block with the floors numbered from 0 to 99. The elevator with a digital counter showing the apartment and the elevator 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 to floor 0 using the elevator he noticed that the counter shows number Stead of88. Then, the elevator started moving the number on the counter changed to 87. After a little thinking Malek came to the conclusion that there are only one explanation for this:one of the sticks of the Counter was broken. Later that day Malek is 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≤99) Good if it's possible that the Digi Tal 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, must write a program, that calculates, this number. Please note this counter always shows the digits. Input

The only line of input contains exactly the digits representing number n (0≤n≤99). Note that N could have a leading zero. Output

The 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 is supposed to show or 89.

In the second sample the good integers is xx, 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.
Test Instructions: There is a two digit clock, there may be some bits of the diode is broken, so there will be different numbers. Give you a displayed number (which may be a bad situation) and ask for all possible situations. the puzzle: the display of 0~9 on the digital clock should be clear. So the corresponding number of the situation is very easy to find. The most straightforward idea is to give each digit a number. Stores 0101 of the signal to indicate a light off. Traverse, in turn, to count possible situations, note that when the number is displayed at this time (1), the corresponding bit of the remaining possible condition must also be shown, the rest is arbitrary. The 10 bits are calculated separately from the digits, and the result is the relationship of the product. code implementation:

#include <iostream> #include <cstdio> #include <cstring> using namespace std; int digit1[7], digit2[7];//10 bit, digit 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}};//initializes int n;
    int main () {scanf ("%d", &n);
    int m = N/10;
    n = n% 10;
    int x=0,y=0;
        Statistics 10 bits for (int i = 0; i <; 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) {f
                Lag=false;
            Break
    }} if (flag) x + +;
        }//statistics digit for (int i = 0; i < 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 &AMP;&Amp
                A[I][J]! = 1) {flag=false;
            Break
    }} if (flag) y++;
    } printf ("%d\n", x*y);
return 0; }

The amount .... The brain is a delay. In fact, the direct number is OK ... But I still insist that I have an advantage in this way. There's still time to prove ... Attach another version:
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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.