QOJ.ac

QOJ

Time Limit: 6 s Memory Limit: 1024 MB Total points: 32

#5807. Interesting Ranges

统计

Problem

A positive integer is a palindrome if its decimal representation (without leading zeros) is a palindromic string (a string that reads the same forwards and backwards). For example, the numbers 5, 77, 363, 4884, 11111, 12121 and 349943 are palindromes. A range of integers is interesting if it contains an even number of palindromes. The range [L, R], with L ≤ R, is defined as the sequence of integers from L to R (inclusive): (L, L+1, L+2, ..., R-1, R). L and R are the range's first and last numbers. The range [L1,R1] is a subrange of [L,R] if L ≤ L1 ≤ R1 ≤ R. Your job is to determine how many interesting subranges of [L,R] there are.

Input

The first line of input gives the number of test cases, T. T test cases follow. Each test case is a single line containing two positive integers, L and R (in that order), separated by a space.

Output

For each test case, output one line. That line should contain "Case #x: y", where x is the case number starting with 1, and y is the number of interesting subranges of [L,R], modulo 1000000007.

Limits

Time limit: 45 6 seconds per test set.

Memory limit: 1 GB.

1 ≤ T ≤ 120

Small dataset (9 Points)

1 ≤ LR ≤ 1013

Large dataset (23 Points)

1 ≤ LR ≤ 10100

Sample

3
1 2
1 7
12 110
Case #1: 1
Case #2: 12
Case #3: 2466

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.