UVA11877

The Coco-Cola Store

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

题意:

3个空瓶子可以换1瓶可乐,输入告诉你会有多少空瓶子,输出回答可以换到多少可乐

方法一:

使用模拟的方法做:

代码:

#include"iostream"
using namespace std;
const int maxn=110;
int main()
{
int ca,n;
while(cin>>n&&n)
{
ca=0;
while(n>2)
{
n-=3;
ca++;
n+=1;
}
if(n==2)
{
ca++;
}
cout<<ca<<endl;
} return 0; } 方法二:
其实只要输出每次的n/2就可以了 代码
#include"iostream"
using namespace std;
int main()
{
int n;
while(cin>>n&&n)
{
if(n!=2)
cout<<n/2<<endl;
else
cout<<1<<endl;
}
return 0;
}

The Coco-Cola Store的更多相关文章

  1. Home · chineking/cola Wiki

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

  2. iOS之App Store上架被拒Legal - 5.1.5问题

    今天在看到App Store 上架过程中,苹果公司反馈的拒绝原因发现了这么一个问题: Legal - 5.1.5 Your app uses background location services ...

  3. 发布APP到app store

    好久好久没写博客了,主要是 都在学习新东西,忙不赢啊. 近段时间在用AC平台学习开发移动APP, 今天开始发布应用. 在ac云控制台编译成ipa后,使用apple提供的Application Load ...

  4. External Configuration Store Pattern 外部配置存储模式

    Move configuration information out of the application deployment package to a centralized location. ...

  5. redux-devtools 浏览器修改Store值

    1. npm install --save-dev redux-devtools 2. npm instal. --redux-devtools-dock-monitor  3. 创建DevTools ...

  6. NopCommerce 在Category 显示 Store List列表

    实现效果如下: 1.在前台Web的Category Menu显示 Store; 2.点击 Store 显示 Store List列表: 3.点击 列表Store 的 Company Name 进入该S ...

  7. Redux原理(一):Store实现分析

    写在前面 写React也有段时间了,一直也是用Redux管理数据流,最近正好有时间分析下源码,一方面希望对Redux有一些理论上的认识:另一方面也学习下框架编程的思维方式. Redux如何管理stat ...

  8. 这两天遇到iphone使用app store下载免费软件,必须验证付款信息才能购物是怎么回事???

    答案: 在你这台设备上再设置一下,具体方法是:1.点设置进入2.点iTunes Store 和App Store 3.点 Apple ID ,如果没设置,设置一下,如果有的,再点击 4.出现一上选择的 ...

  9. 本地数据Store。Cookie,Session,Cache的理解。Timer类主要用于定时性、周期性任务 的触发。刷新Store,Panel

    本地数据Store var monthStore = Ext.create('Ext.data.Store', { storeId : 'monthStore', autoLoad : false, ...

  10. 点击页面判断是否安装app并打开,否则跳转app store的方法

    常常有这样的场景,咱们开发出来的APP需要进行推广,比如在页面顶部来一张大Banner图片,亦或一张二维码.但往往我们都是直接给推广图片加了一个下载链接(App Store中的).所以咱们来模拟一下用 ...

随机推荐

  1. Charles对移动APP抓包(https)

    1.下载安装Charles 2.设置代理 (1)查看默认端口:Proxy->Proxy Settings  在这个页面会看到HTTP Proxy的默认端口是8888 (2)查看当前电脑的IP:H ...

  2. C/C++ 动态库so的生成与调用

    1. Linux-(C/C++)动态链接库生成以及使用(libxxx.so) 2. C++文件如何在linux下生成动态库So,以及如何使用这个动态库 3. c++ 发布动态.so 简记1. 编译生成 ...

  3. 贪心+拓扑排序 AOJ 2456 Usoperanto

    题目传送门 题意:给出一条链,比如x连到y,x一定要在y的左边,且代价是这条链经过的点的权值和,问如何排序使得代价最小 分析:类似拓扑排序,先把入度为0的点入队,把指向该点的所有点按照权值排序,保证这 ...

  4. oozie.log报提示:org.apache.oozie.service.ServiceException: E0104错误 An Admin needs to install the sharelib with oozie-setup.sh and issue the 'oozie admin' CLI command to update sharelib

    不多说,直接上干货! 问题详情 关于怎么启动oozie,我这里不多赘述. Oozie的详细启动步骤(CDH版本的3节点集群) 然后,我在查看 [hadoop@bigdatamaster logs]$ ...

  5. Xml文档数据提取到Excel表中

    近期,财务一位同事,吐槽:<某XX开票软件>导出数据文档只有Xml格式,竟然没有Excel文档,工作起来非常不方便,希望我想想办法.上图: 需求分析:Xml数据----> 提取到Da ...

  6. LinQ的使用

    LinQ:LinQ to Sql类 它是一个集成化的数据访问类,微软将原本需要我们自己动手去编写的一些代码,集成到了这个类中,会自动生成. LinQ的创建: 添加项——添加新项(LinQ to Sql ...

  7. Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bhive.session.id%7D_resources

    原因:环境变量设置问题 <property>    <name>Hive.exec.local.scratchdir</name>    <value> ...

  8. (转)新手学习System Verilog & UVM指南

    从刚接触System Verilog以及后来的VMM,OVM,UVM已经有很多年了,随着电子工业的逐步发展,国内对验证人才的需求也会急剧增加,这从各大招聘网站贴出的职位上也可以看出来,不少朋友可能想尽 ...

  9. 工作笔记:复制文件--从windows到ubuntu,再到fedora

    最近在测试跨平台类库,于是写了一些小程序. 当然主要利用vs进行主要的代码开发.eclipse进行linux的调试. 那么需要不时同步项目文件. 考虑到项目简单,所以没有使用svn. 1. 从wind ...

  10. Vue踩坑第一步,安装Vue最新版本

    学习vue第一步肯定是安装vue-cli,那么肯定想去搜下如何安装vue-cli呢? 网上搜到的结果大都是: npm i vue-cli -g 输入vue -V发现: 输入node -v发现: 自己明 ...