Facebook Hacker Cup 2015 Round 1
Your first-grade math teacher, Mr. Book, has just introduced you to an amazing new concept — primes! According to your notes, a prime is a positive integer greater than that is divisible by only and itself.
Primes seem fun, but without giving you and your 6-year-old colleagues time to consider their implications, he's promptly gone on to define another term: primacity. He explains that the primacity of an integer is the number of distinct primes which divide it. For example, the primacity of is (as it's divisible by primes and ), the primacity of is (as it's divisible by primes , , and ), and the primacity of is (as the only prime it's divisible by is ).
Following his lesson, Mr. Book has given you homework with some rather mean questions of the following form: Given 3 integers , , and , how many integers in the inclusive range have a primacity of exactly ?
Mr. Book probably expects his little homework assignment to take you and your classmates the rest of the year to complete, giving him time to slack off and nap during the remaining math classes. However, you want to learn more things from him instead! Can you use the skills you've learned in your first-grade computer science classes to finish Mr. Book's homework before tomorrow's math class?
Input begins with an integer , the number of homework questions. For each question, there is one line containing 3 space-separated integers: , , and .
For the question, print a line containing
Case #i: followed by the number of integers in the inclusive range with a primacity of .
Explanation of Sample
In the first test case, the numbers in the inclusive range with primacity are , , , , and . All other numbers in this range have primacity .
5 5 15 2 2 10 1 24 42 3 1000000 1000000 1 1000000 1000000 2
Case #1: 5 Case #2: 7 Case #3: 2 Case #4: 0 Case #5: 1
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.