[Solution] Yet Another Chef And Numbers CodeChef Solution
Problem
Chef is again playing with numbers.
He defines the rating of a number as the count of trailing zeros in the product of all the digits of the number.
Chef wants you to find the sum of ratings of all the numbers between the numbers and (excluding ). As the answer can be very large, print it modulo .
Note: If the product of the digits of a number is , the number's rating is defined to be .
Input Format
- The first line contains space-separated integers, and .
Output Format
Output a single integer, the sum of ratings of all the numbers between the numbers and (excluding ). As the answer can be very large, print it modulo .
Explanation:
will have rating as its product of digits = = has trailing zero. All other numbers have a single digit and
thus, no trailing zeroes.
Explanation:
Chef will rate and as as the product of their digits have trailing zeros. All other numbers have no trailing zeroes.
Explanation:
The product of digits of is , which has trailing zeroes. Thus, the rating is .
No comments:
Post a Comment