|
|||
Humble numbers
Peter has a list of his favorite odd prime numbers (). A number is called “humble” if it has no prime divisors other than Peter’s favorite primes. He wants to know how many “humble” numbers exist in a given closed interval . Answering these questions manually would be very time-consuming, so Peter is trying to write a program to solve them. Unfortunately, he got stuck, so it’s up to you to implement it. Examples for P=[3, 5] the first few humble numbers: 1, 3, 5, 9, 15, 25, 27, 45, 75, 81, 125, 135, 225, 243, 375, 405,... in the interval [10,50] there are 4 humble numbers in the interval [100,400] there are 5 humble numbers for P=[7,11,23] the first few humble numbers:: 1, 7, 11, 23, 49, 77, 121, 161, 253, 343, 529, 539, 847, 1127, 1771,... in the interval [10,50] there are 3 humble numbers in the interval [100,400] there are 4 humble numbers Input specificationThe first line containd the number of Peter’s favourite primes. In the next one there different odd prime numbers. The 3. line contains the number of questions, to answer. Each of the next lines has two space separated numbers és . Output specificationlines with the required answer. Constraints
Sample input 1
Sample output 1
Sample input 2
Sample output 2
Sample input 3
Sample output 3
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |