#B3864. Sum of k Lucky Numbers

    ID: 11521 Type: Default 1000ms 256MiB

Sum of k Lucky Numbers

Sum of k Lucky Numbers

Consider a positive integer k. A positive integer is said to be a k lucky number if it satisfies either of the following conditions:

  • Its unit digit is equal to k (i.e. it is of the form \(10n+k\) for some non-negative integer \(n\)).
  • It is divisible by k.

Given three positive integers k, L and R, compute the sum of all k lucky numbers in the interval \([L,R]\) (both inclusive).

Note that a number satisfying both conditions should be counted only once.

inputFormat

The input consists of a single line containing three space-separated integers: k, L and R, where k is a digit (1 ≤ k ≤ 9) and L and R define the range \([L,R]\) (with L ≤ R).

outputFormat

Output a single integer, which is the sum of all k lucky numbers within the range \([L,R]\).

sample

3 1 20
76