UVa 11150 Cola (water ver.)
来源:互联网 发布:大数据概念股有哪些 编辑:程序博客网 时间:2024/05/20 02:52
11150 - Cola
Time limit: 3.000 seconds
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2091
You see the following special offer by the convenience store:
" A bottle of Choco Cola for every 3 empty bottles returned "
Now you decide to buy some (say N) bottles of cola from the store. You would like to know how you can get the most cola from them.
The figure below shows the case where N = 8.Method 1 is the standard way: after finishing your 8 bottles of cola, you have 8 empty bottles. Take 6 of them and you get 2 new bottles of cola. Now after drinking them you have 4 empty bottles, so you take 3 of them to get yet another new cola. Finally, you have only 2 bottles in hand, so you cannot get new cola any more. Hence, you have enjoyed 8 + 2 + 1 = 11 bottles of cola.
You can actually do better! In Method 2, you first borrow an empty bottle from your friend (?! Or the storekeeper??), then you can enjoy 8 + 3 + 1 = 12 bottles of cola! Of course, you will have to return your remaining empty bottle back to your friend.
Input
Input consists of several lines, each containing an integer N (1 ≤N ≤ 200).
Output
For each case, your program should output the maximum number of bottles of cola you can enjoy. You may borrow empty bottles from others, but if you do that, make sure that you have enough bottles afterwards to return to them.
Sample Input
8
Sample Output
12
Note: Drinking too much cola is bad for your health, so... don't try this at home!! :-)
完整代码:
/*0.012s*/#include<cstdio>int main(){int n, sum;while (~scanf("%d", &n)){sum = n;while (n > 2){sum += n / 3;n -= n / 3 * 2;}if (n == 2) ++sum;printf("%d\n", sum);}return 0;}
- UVa 11150 Cola (water ver.)
- UVa 10082 WERTYU (water ver.)
- UVa 10696 f91 (water ver.)
- UVa 79 ClockHands (water ver.)
- UVa 11340 Newspaper (water ver.)
- UVa 514 Rails (water ver.)
- UVa 11150 - Cola
- UVa 11150 Cola
- UVa 10300 Ecological Premium (water ver.)
- UVa 414 Machined Surfaces (water ver.)
- UVa 490 Rotating Sentences (water ver.)
- UVa 445 Marvelous Mazes (water ver.)
- UVa 488 Triangle Wave (water ver.)
- UVa 10783 Odd Sum (water ver.)
- UVa 457 Linear Cellular Automata (water ver.)
- UVa 621 Secret Research (water ver.)
- UVa 11044 Searching for Nessy (water ver.)
- UVa 102 Ecological Bin Packing (water ver.)
- Qt Creator 编码问题
- MonoAndroid打包成apk实机无法运行
- 【fancybox+easyui弹出被遮挡】
- Bath & Body 純白花漾系列
- 数对之差的最大值
- UVa 11150 Cola (water ver.)
- Open Source Sites 书目
- ubuntu下subversion配置
- 标记化结构初始化语法---结构体成员前加小数点
- Eclipse 代码提示功能设置
- js demo setTimeout
- 继承
- 做开发半年总结
- ecshop二次开发——后台增加拣货状态