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). The input terminates with n = 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

不懂算法也会做这题,看了题目,在稿纸上写了几步结果,发现它很有规律,

那就是n=1时,f(n)=0;n>1时,f(2)=1,f(3)=1,f(4)=2,···,f(81)=40,···,所以f(n)=n/2;然后就完事了。

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int t=0,n;
while(t<10)
{
scanf("%d",&n);
if(n==0)
break;
if(n==1)
printf("0\n");
if(n==2||n>2)
printf("%d\n",n/2);
t++;
}
return 0; }

The Coco-Cola Store C(Contest #3 )的更多相关文章

  1. AtCoder Grand Contest 019 A: Ice Tea Store

    tourist出的题诶!想想就很高明,老年选手可能做不太动.不过A题还是按照惯例放水的. AtCoder Grand Contest 019 A: Ice Tea Store 题意:买0.25L,0. ...

  2. App Store审核被拒的23个理由

    原文地址 iOS 应用提交审核要持续一周或者更久,在提交之前,我们一定要进行「自我审查」,避免被拒.ASO100 为大家收集整理了2015年 App Store 审核被拒的23个理由,并且附上官方拒绝 ...

  3. Candy Store

    Candy Store Time Limit: 30000ms, Special Time Limit:75000ms, Memory Limit:65536KB Total submit users ...

  4. Home · chineking/cola Wiki

    Home · chineking/cola Wiki Home Cola Cola是一个分布式的爬虫框架,用户只需编写几个特定的函数,而无需关注分布式运行的细节.任务会自动分配到多台机器上,整个过程对 ...

  5. April Fools Contest 2017 题解&源码(A,数学 B,数学 C,数学 D,字符串 E,数字逻辑 F,排序,卡时间,G,数学)

    A. Numbers Joke time limit per test:2 seconds memory limit per test:64 megabytes input:standard inpu ...

  6. Google APAC----Africa 2010, Qualification Round(Problem A. Store Credit)----Perl 解法

    原题地址链接:https://code.google.com/codejam/contest/351101/dashboard#s=p0 问题描述: Problem You receive a cre ...

  7. Google Code Jam Africa 2010 Qualification Round Problem A. Store Credit

    Google Code Jam Qualification Round Africa 2010 Problem A. Store Credit https://code.google.com/code ...

  8. AtCoder Beginner Contest 115 题解

    题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit ...

  9. 2015多校联合训练赛 hdu 5308 I Wanna Become A 24-Point Master 2015 Multi-University Training Contest 2 构造题

    I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 ...

随机推荐

  1. Java中去除StringBuffer最后一个字符

    原文:http://www.cnblogs.com/shaozhiheng/p/3661714.html 由于编写了这么一段代码: Iterator it3 = set.iterator(); whi ...

  2. perl 语法速查

    同时学perl.python和shell脚本会很容易将它们的语法搞混,本文主要是一个个人的总结,方便要用时的查询. perl基本语法.安装.帮助文档 文件头格式: #!/usr/bin/perl us ...

  3. Tiny PXE Server简介

    Tiny PXE Server简介Tiny PXE Server是一款小巧而功能强大的网启软件.支持DHCP TFTP HTTP BINL DNS等多个协议,支持grub4dos,pxelinux,i ...

  4. Unity3D播放视频

    http://blog.csdn.net/awnuxcvbn/article/details/17618919 点击这里下载视频转换器,该转换器会把其他格式转化为ogv格式,直接被unity识别,不需 ...

  5. Shader for sprite clipping

    Unity3D - Shader for sprite clippinghttp://stackoverflow.com/questions/23165899/unity3d-shader-for-s ...

  6. [maven] 使用问题及思考汇总

    (1)Maven坐标 maven坐标可以唯一标识一个项目,包含四个元素 groupId , artifactId, packaging, version. groupId:一般为团体,公司,项目.如 ...

  7. Ubuntu配置LAMP+MediaWiki及常见问题

    /*在实验室觉得文档传来传去太麻烦了,干脆在实验室内部搞个wiki算了,于是网上搜集搜集资料,配了一个,由于时间仓促,mediaWiki比较高级的东西没来的及细看,等以后用的时候再完善吧*/ 环境:U ...

  8. vs版本的改变处理

    今天要用VS2010打开VS2013,一直觉得VS2010到VS2012只是界面上扁平化的改变,平台工具集有改变但很大程度上可能向上兼容.在网上搜了一些文章,其中有一篇说到一个观点:        从 ...

  9. android 模拟器 使用键盘的配置

    1 打开 android Manageer , 克隆一个设备 2.

  10. hdu----149850 years, 50 colors(最小覆盖点)

    50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...