Hashing
Time limit2sMemory limit128 MB
Count how many of n+1 values of a linear hash modulo m land in an interval [c, d].
- Level
Medium7 of 10
- Topics
- Math, Number theory, Binary search
- Solved
- No attempts yet
Problem
Sanggeun built a hashing function that maps an integer to a value in through :
Given integers , , , and , write a program that counts how many of the hash values
fall within the interval .
Input
The first line contains the number of test cases ().
Each of the next lines contains the integers , , , , , , separated by spaces.
Every number in the input is a non-negative integer.
Output
For each test case, output on its own line the number of indices () satisfying .