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. (Clob的写入和读取-java)更新数据库报错:SQL Error: 1461, SQLState: 72000 ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值

    原 因:某一个字段本为varchar2(1024),但是实际要插入的值超过varchar2允许的最大长度4000时,oracle自动将该字段值转化为Long类型,然后提示插入操作失败. 解决办法: 1 ...

  2. CSS3_新特性预览

    一.强大的CSS选择器 以前我们通常用class. ID 或 tagname 来选择HTML元素,CSS3的选择器强大的难以置信.  它们可以减少在标签中的class和ID的数量更方便的维护样式表.更 ...

  3. 【ros】Create a ROS package:package dependencies报错

    $rospack depends1 beginner_tutorials 报错:Erros:could notn call python function 'rosdep2.rospack.init_ ...

  4. easyui 查询

    <fieldset> <legend>查询</legend> <table style="width: 100%;"> <tr ...

  5. The Network Adapter could not establish the connection问题研究

    最近一个项目会报上述错误,但也不是经常发生,所以很难跟踪,影响不是很大,但每次看到日志中这个错误就会不舒服,还是要想办法解决才是. 错误提示信息很明确是网络适配器不能创建连接. 查了很多资料,并且Or ...

  6. Android GC 那点事

    版权声明:本文由陈昱全原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/170 来源:腾云阁 https://www.qclo ...

  7. python 练习 14

    方法一 #!/usr/bin/python # -*- coding: UTF-8 -*- def fib(n): a,b = 1,1 for i in range(n-1): a,b = b,a+b ...

  8. Junit4入门

    eclipse自带junit包,可右键直接新建junit类 静态引入:import static org.junit.Assert.* assert.*是类,静态引入会引入assert里的所有静态方法 ...

  9. 在ubuntu(linux)下安装vim,以及vim的常用命令

    介绍vim: vim是一种编辑器,自我感觉这东西好用,就是现在有些不太习惯 如何安装: 如果是使用redhat ,系统自带着vi和vim 如果是使用ubuntu,建议使用apt-get命令, 可以尝试 ...

  10. hdu-----(4857)逃生(拓扑排序)

    逃生 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...