ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1385. Interesting Number

Beautiful accepted
Posted by Axmed 4 Aug 2025 16:26
We have number n = a * (10 ^ n) + b.

n mod a = 0
and
n mod b = 0

If n mod a = 0 that b mod a = 0.
If n mod b = 0 that a * (10 ^ n) mod b = 0

We have now
b mod a = 0
a * (10 ^ n) mod b = 0

Ok, now let's imagine b = k * a. First condition is fulfilled.
a * (10 ^ n) / (k * a) = 10 ^ n / k

K is divider of 10 ^ n.
Let's note that k is less then 10. Why? Because a * 10 have n + 1 digit but b must have n digit.
Now for all 1 <= k <= 9 and 10^n mod k = 0 we calculate how many good numbers a we can use, a * k must have n digit that 10 ^ (n - 1) <= a <= (10 ^ n - 1) // k. Sum of all good ways to choose a and k is answer!