Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2012 /round3 /divisor_function_optimization.html
wjomlex's picture
2012 Problems
91a79e0 verified
raw
history blame
1.76 kB
<p> Let <b>d(N)</b> be the number of positive divisors of positive integer <b>N</b>.
Consider the infinite sequence <b>x(n) = d(n)<sup>a</sup> / n<sup>b</sup>, n = 1, 2, 3, …</b>
where <b>a</b> and <b>b</b> are fixed positive integers.
It can be shown that this sequence tends to zero. Hence it attains its maximum. Denote it by <b>p/q</b> where <b>p</b> and <b>q</b> are co-prime positive integers. Your task is for given <b>a</b> and <b>b</b> find <b>p</b> and <b>q</b> modulo <b>M = 10<sup>9</sup>+7</b>. But to keep input and output small you will be given tuples <b>(b1; b2; a1; a2; c)</b> and need to calculate the sum of <b>(p mod M)</b> for all pairs <b>(a; b)</b> such that <b>b1 &le; b &le; b2</b>, <b>a1 &le; a &le; a2</b> and <b> a &le; c*b</b>, and the same sum for <b>q</b>-values. </p>
<h3>Input</h3>
<p>The first line contains a positive integer <b>T</b>, the number of test cases. <b>T</b> test cases follow. The only line of each test case contains five space separated positive integers <b>b1, b2, a1, a2</b> and <b>c</b>.</p>
<h3>Output</h3>
<p>For each of the test cases numbered in order from <b>1</b> to <b>T</b>, output "Case #i: " followed by a space separated pair of integers: the sum of <b>(p mod M)</b> for all pairs <b>(a; b)</b> mentioned above and the sum of <b>(q mod M)</b> for all such pairs. Note that you need to find the sum of residues not the residue of sum (see testcase 3 as a reference).</p>
<h3>Constraints</h3>
<p>
1 &le; <b>T</b> &le; 20<br/>
1 &le; <b>b1</b> &le; <b>b2</b> &le; 10,000<br/>
1 &le; <b>a1</b> &le; <b>a2</b> &le; 250,000<br/>
1 &le; <b>c</b> &le; 25<br/>
in each testcase the total number of pairs <b>(a; b)</b> for which the answer should be calculated does not exceed 100,000<br/></p>