Digit Sum
View as PDF
Submit solution
Points:
100
Time limit:
1.0s
PyPy 3
3.0s
Python 3
3.0s
Memory limit:
256M
Problem type
Given three integers ,
, and
, count how many integers
satisfy
and have digit sum divisible by
.
The digit sum of a number is the sum of its decimal digits. For example, the digit sum of
is
.
Input
The input consists of a single line containing three integers ,
, and
.
Output
Print the number of valid integers in the range.
Constraints
and
do not contain leading zeroes, unless the number is exactly
0
Example 1
Input
1 20 2
Output
10
Explanation
The valid values are ,
,
,
,
,
,
,
,
, and
.
Example 2
Input
0 25 3
Output
9
Example 3
Input
2040 2050 5
Output
2
Explanation
Only and
have digit sum divisible by
.
Comments