The Coco-Cola Store C(Contest #3 )
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 )的更多相关文章
- AtCoder Grand Contest 019 A: Ice Tea Store
tourist出的题诶!想想就很高明,老年选手可能做不太动.不过A题还是按照惯例放水的. AtCoder Grand Contest 019 A: Ice Tea Store 题意:买0.25L,0. ...
- App Store审核被拒的23个理由
原文地址 iOS 应用提交审核要持续一周或者更久,在提交之前,我们一定要进行「自我审查」,避免被拒.ASO100 为大家收集整理了2015年 App Store 审核被拒的23个理由,并且附上官方拒绝 ...
- Candy Store
Candy Store Time Limit: 30000ms, Special Time Limit:75000ms, Memory Limit:65536KB Total submit users ...
- Home · chineking/cola Wiki
Home · chineking/cola Wiki Home Cola Cola是一个分布式的爬虫框架,用户只需编写几个特定的函数,而无需关注分布式运行的细节.任务会自动分配到多台机器上,整个过程对 ...
- 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 ...
- 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 ...
- 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 ...
- AtCoder Beginner Contest 115 题解
题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit ...
- 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 ...
随机推荐
- D3.js 选择元素和绑定数据/使用数据
选择元素和绑定数据是 D3 最基础的内容,本文将对其进行一个简单的介绍. 一.如何选择元素 在 D3 中,用于选择元素的函数有两个: d3.select():是选择所有指定元素的第一个 d3.sele ...
- MYSQL 【汇总数据】 【分组数据】 学习记录
分组数据 1,创建分组:
- CodeIgniter配置之SESSION
刚使用Codeigniter时也被其中的SESSION迷惑过,后来就再也没用过CI自带的SESSION,想必还是有必要整理一下SESSION.为弄清CI中的SESSION,先来说一下PHP中SESSI ...
- Jenkins运行完Test后,把ngreport生成的测试报告 拷贝到相应的文件夹
F:cd F:\program\apache-tomcat-7.0.67\webapps\Set currentPath=F:\program\apache-tomcat-7.0.67\webapps ...
- eclipse 新建 maven 项目 步骤(初级入门新手)
安装 maven(百度) 和在eclipse 中svn(上一篇) 修改 maven 本地仓库 eclipse 属性 maven--> installations-->添加新的 自定义安装的 ...
- 创建和使用Windows静态链接库
首先明确这篇文章的目的,我希望大家能够通过这篇文章了解一下如何在实际工作中创建和使用Windows平台下的静态链接库.关于链接库的概念,希望大家参考维基百科"Library"词条( ...
- css读书笔记2:css工作原理
css就是一种先选择html元素,然后设定选中元素css属性的机制.css选择符合要应用的样式构成一条css规则. 为文档添加样式的3种方法: 1.行内样式,直接写在特定标签的style属性中:2.嵌 ...
- Android Support Library控件详细介绍之RecyclerView
RecyclerView控件 依赖 compile 'com.android.support:recyclerview-v7:24.1.1'RecyclerView也是容器控件,大多数的效果显示可通 ...
- 反编译工具reflector破解方法
文件下载:http://files.cnblogs.com/lori/Red.Gate.Reflector7.6.rar 破解方法: 1. 断网2. 运行.NET Reflector,点击Help - ...
- python中的popen和subprocess
import os from subprocess import Popen, PIPE res = os.popen('xx.exe E:\\test\\file1 E:\\test\\file2' ...