Once upon a time, there is a special coco-cola store. If you return three empty bottles to the shop,
you’ll get a full bottle of coco-cola to drink. If you have n empty bottles right in your hand, how many
full bottles of coco-cola can you drink?
Input
There will be at most 10 test cases, each containing a single line with an integer
n
(1<=n<=100). Theinput terminates withn= 0, which should not be processed.
Output
For each test case, print the number of full bottles of coco-cola that you can drink.
Spoiler
Let me tell you how to drink 5 full bottles with 10 empty bottles: get 3 full bottles with 9 empty
bottles, drink them to get 3 empty bottles, and again get a full bottle from them. Now you have 2
empty bottles.
Borrow another empty bottle from the shop
, then get another full bottle. Drink it, and
finally return this empty bottle to the shop!
Sample Input
3
10
81
0
Sample Output
1
5
40

程序分析:此题的大概意思就是3空汽水瓶子可以换一瓶汽水,但是值得注意的就是每3个空瓶子得1瓶汽水,但同时也会多得到一个空瓶子。

程序代码:

#include<cstdio>
#include<iostream>
using namespace std;
int main()
{int T,n,i=;
while(scanf("%d",&n)==&&n)
{
if(n<)
{cout<<<<endl;
continue;
} while(n>)
{n-=;
i++;
n++;
}
i+=n;
cout<<i<<endl;
i=;
}
return ;
}

ACM第三次比赛UVA11877 The Coco-Cola Store的更多相关文章

  1. ACM第三次比赛 Big Chocolate

    Problem G Big Chocolate Mohammad has recently visited Switzerland . As he loves his friends very muc ...

  2. acm的第一场比赛的总结

    6.4-6.5号很激动的去湖南湘潭打了一场邀请赛,这是第一次acm的旅程吧.毕竟大一上册刚开始接触c,然后现在就能抱着学长的大腿(拖着学长的后腿)打比赛,也是有一点小小的激动. 第一天很早就起床了,由 ...

  3. 2015年ACM长春区域赛比赛感悟

    距离长春区域赛结束已经4天了,是时候整理一下这次比赛的点点滴滴了. 也是在比赛前一周才得到通知要我参加长春区域赛,当时也是既兴奋又感到有很大的压力,毕竟我的第一场比赛就是区域赛水平,还是很有挑战性的. ...

  4. [ACM] hdu 1285 确定比赛 (拓扑排序)

    确定比赛 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  5. [ACM] hdu 1285 确定比赛名次 (拓扑排序)

    确定比赛名次 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  6. #【Python】【demo实验23】【练习实例】【 三人比赛顺序问题 】

    原题: 两个乒乓球队进行比赛,各出三人.甲队为a,b,c三人,乙队为x,y,z三人.已抽签决定比赛名单.有人向队员打听比赛的名单.a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单. 我的 ...

  7. ACM: HDU 1285 确定比赛名次 - 拓扑排序

     HDU 1285 确定比赛名次 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u De ...

  8. ACM、OI等比赛中的程序对拍问题

    多年前请教于ZXYTIM(zxy)大牛,现在把windows环境下的版本贴出来. 手动数据调试效率太低,程序对拍还是非常实用的,特别适用于OI.蓝桥杯等这些比赛规则.可以用于暴力与AC算法之间的对拍. ...

  9. 6、Cocos2dx 3.0游戏开发的基本概念找个小三场比赛

    重开发人员的劳动成果,转载的时候请务必注明出处:http://blog.csdn.net/haomengzhu/article/details/27689713 郝萌主友情提示: 人是习惯的产物,当你 ...

随机推荐

  1. QQ聊天原理初识

    1:qq之间文件的传输是通过p2p通信进行的. 2:qq之间的表情发送实际上就是文字的发送,是client再接受到文字之后在本地自己进行转换 3:qq之间的通信既能够通过udp也能够通过Tcp 尽管u ...

  2. iOS --- [持续更新中] iOS移动开发中的优质资源

    在我们做iOS APP的开发过程中, 须要非常多设计, 产品, 技术, 运营等方面的技巧和资源. 现将其整理汇总, 本文会一直持续更新. 敬请关注. 设计 Dribbble Dribbble是一个面向 ...

  3. Qt5官方demo分析集11——Qt Quick Particles Examples - Affectors

    在这个系列中的所有文章都可以在这里查看http://blog.csdn.net/cloud_castle/article/category/2123873 接上文Qt5官方demo解析集10--Qt ...

  4. Java,js,多条件split字符分割

    后台字符串分割处理: String s = "i20002/400|i3030/300";        String[] s1 = s.split("\\||/&quo ...

  5. JS拖动浮动DIV

    <!DOCTYPE html> <html> <head> <meta charset="utf8"> <title>j ...

  6. js中定义用字符串拼接起来的变量名的变量

    用对象的形式 你的问题可以通过js的对象实现 var ovar = {}; for(var i=0;i<10;i++){ ovar['var_'+i]=''; } 3用数组的形式 var arr ...

  7. CentOS 6.5系统安装配置图解教程(详细图文)

    转载:http://www.jb51.net/os/128751.html

  8. poj 1458 Common Subsequence(区间dp)

    题目链接:http://poj.org/problem?id=1458 思路分析:经典的最长公共子序列问题(longest-common-subsequence proble),使用动态规划解题. 1 ...

  9. Hadoop Security Authentication Terminology --Kerberos

    Hadoop Security Authentication Terminology --Kerberos What is kinit? Kinit -  obtain and cache Kerbe ...

  10. opencv是什么

    OpenCV是一个用于图像处理.分析.机器视觉方面的开源函数库.       不管你是做科学研究,还是商业应用,opencv都能够作为你理想的工具库,由于,对于这两者,它全然是免费的.该库採用C及C+ ...