forked from keshavnandan/Topcoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKitayutaMart2.html
5 lines (5 loc) · 4.14 KB
/
KitayutaMart2.html
1
2
3
4
5
<html><body bgcolor="#000000" text="#ffffff"><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>    </td><td><p><i>This problem statement contains superscripts that may not display properly outside the applet.</i></p>
<p></p>
<p>Kitayuta Mart is the largest supermarket in Shuseki Kingdom, offering a great variety of food and household products. The main products are fruits, especially apples. The price system is a little special: the <i>original price</i> of an apple is <b>K</b> yen (the currency of the kingdom). However, if a customer wants to buy more than one apple, the second apple will cost 2*<b>K</b> yen, the third apple will cost 2<sup>2</sup>*<b>K</b> yen, and so on. In general, if a customer is buying <i>n</i> apples, the <i>actual price</i> of the <i>i</i>-th (1 <= <i>i</i> <= <i>n</i>) apple will be 2<sup><i>i</i>-1</sup>*<b>K</b> yen.</p>
<p></p>
<p>Lun the dog loves apples. She has just bought some number of apples at Kitayuta Mart. The prices of those apples were calculated using the above formula. The total she paid for her apples was <b>T</b> yen. You are given two ints: <b>K</b> and <b>T</b>. Find and return the number of the apples that Lun has bought. It is guaranteed that <b>K</b> and <b>T</b> are such that the answer exists and is unique.</p></td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>    </td><td><table><tr><td>Class:</td><td>KitayutaMart2</td></tr><tr><td>Method:</td><td>numBought</td></tr><tr><td>Parameters:</td><td>int, int</td></tr><tr><td>Returns:</td><td>int</td></tr><tr><td>Method signature:</td><td>int numBought(int K, int T)</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>256</td></tr><tr><td>Stack limit (MB):</td><td>256</td></tr></table></td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>K</b> will be between 80 and 160, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td><b>T</b> will be between 80 and 163,680, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>The input will be such that the answer exists and is unique.</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>100</pre></td></tr><tr><td><pre>100</pre></td></tr></table></td></tr><tr><td><pre>Returns: 1</pre></td></tr><tr><td><table><tr><td colspan="2">If she buys only one apple, the price will just be <b>K</b> yen.</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>100</pre></td></tr><tr><td><pre>300</pre></td></tr></table></td></tr><tr><td><pre>Returns: 2</pre></td></tr><tr><td><table><tr><td colspan="2">The second apple will cost 2*100 = 200 yen, for the total price of 100 + 200 = 300 yen.</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>150</pre></td></tr><tr><td><pre>1050</pre></td></tr></table></td></tr><tr><td><pre>Returns: 3</pre></td></tr><tr><td><table><tr><td colspan="2">150 + 2*150 + 2<sup>2</sup>*150 = 150 + 300 + 600 = 1050.</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>160</pre></td></tr><tr><td><pre>163680</pre></td></tr></table></td></tr><tr><td><pre>Returns: 10</pre></td></tr><tr><td><table><tr><td colspan="2"></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>