#P16737. [GKS 2019 #E] Street Checkers

    ID: 19069 远端评测题 3000ms 1024MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学2019数论素数判断Google Kick Start

[GKS 2019 #E] Street Checkers

Problem Description

Alice and Bob are playing a new virtual reality team game - Street Checkers. The game is set on an insanely long street divided into tiles which are numbered from 00 to 10910^9(inclusive of both). At the start of the game, Alice and Bob are standing on tile number 00 and are given a random number XX in range [LL, RR] (both ends are inclusive). Alice only jumps to odd numbered tiles, while Bob only jumps to even numbered tiles. If the number on the tile divides XX, then the player landing on it has to color it with their favorite color. The game is over after tile XX has been colored.

A game is considered interesting by both the players if the absolute difference between the number of tiles painted by each is not greater than 22. Help Alice and Bob find how many numbers in the interval [LL, RR] could make for an interesting game.

Input Format

The first line of the input gives the number of test cases, TT. TT lines follow each containing two integers LL and RR, the start and end of the interval used to generate the random number XX.

Output Format

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the count of numbers in interval [LL, RR] which results in an interesting game for Alice and Bob.

2
5 10
102 102
Case #1: 5
Case #2: 1

Hint

For the first sample case, let us look at all the possible number in range [5,10][5, 10]:

  • 55 - Alice would paint 22 tiles : {1,5}\{1, 5\}, and Bob would not paint any tile. The game would be interesting since the absolute difference is 22.
  • 66 - Alice would paint 22 tiles : {1,3}\{1, 3\}, and Bob would paint 22 tiles : {2,6}\{2, 6\}. The game would be interesting since the absolute difference is 00.
  • 77 - Alice would paint 22 tiles : {1,7}\{1, 7\}, and Bob would not paint any tile. The game would be interesting since the absolute difference is 22.
  • 88 - Alice would paint 11 tile : {1}\{1\}, and Bob would paint 33 tiles : {2,4,8}\{2, 4, 8\}. The game would be interesting since the absolute difference is 22.
  • 99 - Alice would paint 22 tiles : {1,3,9}\{1, 3, 9\}, and Bob would not paint any tile. The game would not be interesting since the absolute difference is greater than 22.
  • 1010 - Alice would paint 22 tiles : {1,5}\{1, 5\}, and Bob would paint 22 tiles : {2,10}\{2, 10\}. The game would be interesting since the absolute difference is 00.

Thus, the answer for this test case is 55.

In the second sample case, we have only one number 102102. Alice would paint 44 tiles : {1,3,17,51}\{1, 3, 17, 51\} while Bob would paint 44 tiles : {2,6,34,102}\{2, 6, 34, 102\}. The game would be interesting since the absolute difference is 00.

Limits

1T1001 \le T \le 100.

0RL1050 \le R - L \le 10^5.

Test set 1 (Visible)

1LR1061 \le L \le R \le 10^6.

Test set 2 (Hidden)

1LR1091 \le L \le R \le 10^9.