#P16737. [GKS 2019 #E] Street Checkers
[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 to (inclusive of both). At the start of the game, Alice and Bob are standing on tile number and are given a random number in range [, ] (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 , then the player landing on it has to color it with their favorite color. The game is over after tile 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 . Help Alice and Bob find how many numbers in the interval [, ] could make for an interesting game.
Input Format
The first line of the input gives the number of test cases, . lines follow each containing two integers and , the start and end of the interval used to generate the random number .
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 [, ] 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 :
- - Alice would paint tiles : , and Bob would not paint any tile. The game would be interesting since the absolute difference is .
- - Alice would paint tiles : , and Bob would paint tiles : . The game would be interesting since the absolute difference is .
- - Alice would paint tiles : , and Bob would not paint any tile. The game would be interesting since the absolute difference is .
- - Alice would paint tile : , and Bob would paint tiles : . The game would be interesting since the absolute difference is .
- - Alice would paint tiles : , and Bob would not paint any tile. The game would not be interesting since the absolute difference is greater than .
- - Alice would paint tiles : , and Bob would paint tiles : . The game would be interesting since the absolute difference is .
Thus, the answer for this test case is .
In the second sample case, we have only one number . Alice would paint tiles : while Bob would paint tiles : . The game would be interesting since the absolute difference is .
Limits
.
.
Test set 1 (Visible)
.
Test set 2 (Hidden)
.