FoxIntegerLevelThree
TCO11 Qual 2 · 2011-05-07 · by wrong
Problem Statement
Fox Jiro likes to ponder integers. Today he thought about the following things.
First, he defines a function s(n) for positive integers n. s(n) indicates the sum of all digits of n in base 10. For example, s(58) = 5+8 = 13.
Next, he defines another function d(n) for positive integers n. d(n) applies function s for n repeatedly until the result has only one digit. For example, consider d(58). First, we calculate s(58) and get 13. 13 has two digits, so we calculate s(13) and get 4. So, d(58) = 4.
He says an integer x is representable if and only if there is at least one positive integer y such that y * d(y) = x. You are given a
Constraints
- min will be between 1 and 10,000,000,000 (10^10), inclusive.
- max will be between min and 10,000,000,000 (10^10), inclusive.
10 16 Returns: 2
The representable numbers are 10 (= 10 * d(10)) and 16 (= 4 * d(4)).
123 123 Returns: 0
123 is not representable.
160 160 Returns: 1
160 can be represented by two ways: 160 = 40 * d(40) 160 = 32 * d(32)
47 58 Returns: 4
123456789 9876543210 Returns: 2618024258
Submissions are judged against all 121 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FoxIntegerLevelThree with a public method long long count(long long min, long long max) · 121 test cases · 2 s / 256 MB per case