Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2015 /round1 /homework.html
wjomlex's picture
2015 Problems
761e24d verified
raw
history blame
2.37 kB
<p>
Your first-grade math teacher, Mr. Book, has just introduced you to an amazing new concept &mdash; primes! According to your notes, a prime is a positive integer greater than 1 that is divisible by only 1 and itself.
</p>
<p>
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 12 is 2 (as it's divisible by primes 2 and 3), the primacity of 550 is 3 (as it's divisible by primes 2, 5, and 11), and the primacity of 7 is 1 (as the only prime it's divisible by is 7).
</p>
<p>
Following his lesson, Mr. Book has given you homework with some rather mean questions of the following form: Given 3 integers <strong>A</strong>, <strong>B</strong>, and <strong>K</strong>, how many integers in the inclusive range [<strong>A</strong>, <strong>B</strong>] have a primacity of exactly <strong>K</strong>?
</p>
<p>
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?
</p>
<h3>Input</h3>
<p>
Input begins with an integer <strong>T</strong>, the number of homework questions. For each question, there is one line containing 3 space-separated integers: <strong>A</strong>, <strong>B</strong>, and <strong>K</strong>.
</p>
<h3>Output</h3>
<p>
For the <strong>i</strong>th question, print a line containing "Case #<strong>i</strong>: " followed by the number of integers in the inclusive range [<strong>A</strong>, <strong>B</strong>] with a primacity of <strong>K</strong>.
</p>
<h3>Constraints</h3>
<p>
1 &le; <strong>T</strong> &le; 100 <br />
2 &le; <strong>A</strong> &le; <strong> B</strong> &le; 10<sup>7</sup> <br />
1 &le; <strong>K</strong> &le; 10<sup>9</sup> <br />
</p>
<h3>Explanation of Sample</h3>
<p>
In the first test case, the numbers in the inclusive range [5, 15] with primacity 2 are 6, 10, 12, 14, and 15. All other numbers in this range have primacity 1.
</p>