p169.ans1
======================
8

=================
p169.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n;

void read() { cin >> n; }

void solve() {
    // Closed-form count of perfect k-digit numbers (derived from the digit
    // structure of good/perfect numbers): k == 1 gives 8, otherwise the answer
    // depends only on k mod 6 / k mod 3 -- 4 when k % 6 == 1, 3 when
    // k % 3 == 1, and 1 in every other case.

    if(n == 1) {
        cout << 8 << '\n';
    } else if(n % 6 == 1) {
        cout << 4 << '\n';
    } else if(n % 3 == 1) {
        cout << 3 << '\n';
    } else {
        cout << 1 << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
p169.in1
======================
1

=================
p169.py
======================
n = int(input())

if n == 1:
    print(8)
elif n % 6 == 1:
    print(4)
elif n % 3 == 1:
    print(3)
else:
    print(1)

=================
statement.txt
======================
169. Numbers
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard
output: standard



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 test(s)

Input
1

Output
8
Author:	All-Russian mathematical olympiad jury
Resource:	District mathematical olympiad, 8th form
Date:	

=================
