Hamming Sequence
Time limit1sMemory limit128 MB
Given three primes and an index i, find the i-th smallest number greater than 1 whose prime factors all lie among those three primes.
- Level
Hard8 of 10
- Topics
- Math, Number theory, Binary search, Combinatorics
- Solved
- No attempts yet
Problem
For three primes , , , define the Hamming sequence .
is the ascending list of natural numbers greater than whose only prime factors are among , , . (In particular, is not included.)
For example, , and its fifth number is .
Input
The first line contains , , , and . All four integers are less than .
Output
Print the -th number of . The printed number is less than .