Equal Digit Products
Time limit1sMemory limit128 MB
Count N-digit numbers whose digits in odd positions have the same product as the digits in even positions.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
Marija likes to play with all sorts of things, numbers among them. This time she asks the following. Given a natural number , how many natural numbers with exactly digits have the product of the digits in even positions equal to the product of the digits in odd positions?
Positions are numbered from left to right. The leading digit, the one with the largest place value, is position 1, so it lies in an odd position. Since has exactly digits, the leading digit is not 0.
A product over no digits is defined as 1. So when is 1 there is no even position and the product of the digits in even positions is 1.
Input
The first and only line contains a natural number ().
Output
Print the number of natural numbers that satisfy the condition.