Numbers

来源:互联网 发布:工程预算软件哪个好 编辑:程序博客网 时间:2024/05/16 19:56

Description

Let us call P(n) - the product of all digits of number n (in decimal notation).
For example, P(1243)=1*2*4*3=24; P(198501243)=0.
Let us call n to be a good number, if (p(n)<>0) and (n mod P(n)=0).
Let us call n to be a perfect number, if both n and n+1 are good numbers.

You are to write a program, which, given the number K, counts all such
numbers n that n is perfect and n contains exactly K digits in decimal notation.

Input

Only one number K (1<=K<=1000000) is written in input.

Output

Output the total number of perfect k-digit numbers.

Sample Input


Input
1

Output
8


题目大意:

给一个k位的数,问具有k位的数里。有多少个数是perfect number。perfect number题目描述的性质。


我的做法是:看输入数据就知道perfect number必定不会太多.将前几位的数据输出来观察后,找到规律即可解。


#include <iostream>using namespace std;void input(){    long long n;    cin >> n;    if (n == 1)    {        cout << 8 << endl;    }    else if ((n - 1) % 3 == 0)                  //(n - 1) % 3时多2,  如四位 1111 1112 1115    {        if ((n - 1) % 6 == 0)                   //(n - 1) % 6时多3    如七位 1111111 1111112 1111115 1111116        {            cout << 4 << endl;        }        else        {            cout << 3 << endl;        }    }    else    {        cout << 1 << endl;                      //普通为1              如两位 11 三位 111    }}int main(){    input();    return 0;}