+</td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>    </td><td><table><tr><td>Class:</td><td>FloatingPoint</td></tr><tr><td>Method:</td><td>representations</td></tr><tr><td>Parameters:</td><td>int, int, int</td></tr><tr><td>Returns:</td><td>int</td></tr><tr><td>Method signature:</td><td>int representations(int number, int mantissa, int exponent)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td colspan="2"><h3>Limits</h3></td></tr><tr><td>    </td><td><table><tr><td>Time limit (s):</td><td>2.000</td></tr><tr><td>Memory limit (MB):</td><td>64</td></tr></table></td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>number</b> will be between 1 and 1000000000 (10<sup>9</sup>), inclusive.</td></tr><tr><td align="center" valign="top">-</td><td><b>mantissa</b> will be between 1 and 20, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td><b>exponent</b> will be between 1 and 20, inclusive.</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>24</pre></td></tr><tr><td><pre>4</pre></td></tr><tr><td><pre>2</pre></td></tr></table></td></tr><tr><td><pre>Returns: 3</pre></td></tr><tr><td><table><tr><td colspan="2">Example from the problem statement.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>1</pre></td></tr><tr><td><pre>3</pre></td></tr><tr><td><pre>3</pre></td></tr></table></td></tr><tr><td><pre>Returns: 1</pre></td></tr><tr><td><table><tr><td colspan="2">The number 1 can be represented in only one way (regardless of the mantissa and exponent sizes).</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>8</pre></td></tr><tr><td><pre>3</pre></td></tr><tr><td><pre>3</pre></td></tr></table></td></tr><tr><td><pre>Returns: 3</pre></td></tr><tr><td><table><tr><td colspan="2">To represent the number 8 we can choose (ordered by exponent) from: 8*2<sup>0</sup>, 4*2<sup>1</sup>, 2*2<sup>2</sup>, 1*2<sup>3</sup>. The exponent has the range for larger numbers, but the smallest mantissa is used in the last case in this list.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>16</pre></td></tr><tr><td><pre>5</pre></td></tr><tr><td><pre>2</pre></td></tr></table></td></tr><tr><td><pre>Returns: 4</pre></td></tr><tr><td><table><tr><td colspan="2">To represent the number 16 we can choose (ordered by exponent) from: 16*2<sup>0</sup>, 8*2<sup>1</sup>, 4*2<sup>2</sup>, and 2*2<sup>3</sup>. Here the next possibility (1*2<sup>4</sup>) would require an exponent that cannot be represented with 3 bits.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">4)</td><td></td></tr><tr><td>    </td><td><table><tr><td><table><tr><td><pre>17408</pre></td></tr><tr><td><pre>10</pre></td></tr><tr><td><pre>10</pre></td></tr></table></td></tr><tr><td><pre>Returns: 6</pre></td></tr><tr><td><table><tr><td colspan="2">Note that 17408 = 17*2<sup>10</sup>. Thus the number 17 (or 1001 in binary notation) can be shifted to fit in 6 positions within the 10 mantissa bits (using leading or trailing zeros): from 17*2<sup>10</sup> to 544*2<sup>5</sup>. Any exponent less than 5 would overflow the mantissa.</td></tr></table></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. </p></body></html>
0 commit comments