#Lutece0892. Exponential Towers
Exponential Towers
Migrated from Lutece 892 Exponential Towers
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
The number can be written as a power in several ways: , and . It can be written as , of course, but that does not count as a power.
We want to go some steps further. To do so, it is convenient to use ^
for exponentiation, so we define .
The number then can be also written as 2^2^3
, or as 4^2^2
.
Recall that ^
is right associative, so 2^2^3
means 2^(2^3)
.
We define a tower of powers of height to be an expression of the form $a_1\verb|^|a_2\verb|^|a_3\verb|^|\ldots \verb|^| a_k$, with , and integers .
Given a tower of powers of height , representing some integer , how many towers of powers of height at least represent ?
Input
The input file contains several test cases, each on a separate line. Each test case has the form , where , and are integers, .
Output
For each test case, print the number of ways the number can be represented as a tower of powers of height at least three.
The magic number is carefully chosen such that the output is always less than .
Samples
4^2^2
8^12^2
8192^8192^8192
2^900^576
2
10
1258112
342025379
Resources
Northwestern European Regional Contest 2013