Submission #37431921


Source Code Expand

VERY_LARGE_PRIME = 10 ** 9 + 7
l, r = gets.chomp.split.map(&:to_i)

def triangular(n)
  n * (n + 1) / 2
end

current = l
current_digits = l.to_s.length
digits_count = 0
while current <= r
  max_of_current = [10 ** current_digits - 1, r].min

  digits_count += triangular(max_of_current) * current_digits
  digits_count -= triangular(current - 1) * current_digits if current > 1

  current_digits += 1
  current = max_of_current + 1
end

puts digits_count % VERY_LARGE_PRIME

Submission Info

Submission Time
Task 082 - Counting Numbers(★3)
User thatblue
Language Ruby (2.7.1)
Score 3
Code Size 495 Byte
Status AC
Exec Time 61 ms
Memory 14380 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 3 / 3
Status
AC × 4
AC × 39
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 03_large_01.txt, 03_large_02.txt, 03_large_03.txt, 03_large_04.txt, 03_large_05.txt, 04_wide_01.txt, 04_wide_02.txt, 04_wide_03.txt, 04_wide_04.txt, 04_wide_05.txt, 04_wide_06.txt, 04_wide_07.txt, 04_wide_08.txt, 04_wide_09.txt, 04_wide_10.txt, 05_border_01.txt, 05_border_02.txt, 05_border_03.txt, 05_border_04.txt, 05_border_05.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
01_random_01.txt AC 56 ms 14148 KiB
01_random_02.txt AC 54 ms 14184 KiB
01_random_03.txt AC 55 ms 14360 KiB
01_random_04.txt AC 61 ms 14028 KiB
01_random_05.txt AC 55 ms 14192 KiB
01_random_06.txt AC 55 ms 14264 KiB
01_random_07.txt AC 54 ms 13972 KiB
01_random_08.txt AC 56 ms 14244 KiB
01_random_09.txt AC 56 ms 14040 KiB
01_random_10.txt AC 59 ms 14196 KiB
02_small_01.txt AC 56 ms 14232 KiB
02_small_02.txt AC 56 ms 14156 KiB
02_small_03.txt AC 56 ms 14232 KiB
02_small_04.txt AC 56 ms 14088 KiB
02_small_05.txt AC 57 ms 13980 KiB
03_large_01.txt AC 55 ms 14216 KiB
03_large_02.txt AC 57 ms 14128 KiB
03_large_03.txt AC 50 ms 14176 KiB
03_large_04.txt AC 56 ms 14192 KiB
03_large_05.txt AC 58 ms 14380 KiB
04_wide_01.txt AC 56 ms 14216 KiB
04_wide_02.txt AC 55 ms 14232 KiB
04_wide_03.txt AC 57 ms 14224 KiB
04_wide_04.txt AC 57 ms 14220 KiB
04_wide_05.txt AC 55 ms 14312 KiB
04_wide_06.txt AC 57 ms 14076 KiB
04_wide_07.txt AC 52 ms 14164 KiB
04_wide_08.txt AC 55 ms 14236 KiB
04_wide_09.txt AC 55 ms 14104 KiB
04_wide_10.txt AC 54 ms 14232 KiB
05_border_01.txt AC 53 ms 14048 KiB
05_border_02.txt AC 56 ms 14016 KiB
05_border_03.txt AC 52 ms 14240 KiB
05_border_04.txt AC 55 ms 14096 KiB
05_border_05.txt AC 56 ms 14208 KiB
sample_01.txt AC 55 ms 14044 KiB
sample_02.txt AC 55 ms 14152 KiB
sample_03.txt AC 55 ms 14080 KiB
sample_04.txt AC 55 ms 14144 KiB