Google Code Jam 2014 资格赛:Problem B. Cookie Clicker Alpha
Introduction
Cookie Clicker is a Javascript game by Orteil, where players click on a picture of a giant cookie. Clicking on the giant cookie gives them cookies. They can spend those cookies to buy buildings. Those buildings help them get even more cookies. Like this problem, the game is very cookie-focused. This problem has a similar idea, but it does not assume you have played Cookie Clicker. Please don't go play it now: it might be a long time before you come back.
Problem
In this problem, you start with 0 cookies. You gain cookies at a rate of 2 cookies per second, by clicking on a giant cookie. Any time you have at least C cookies, you can buy a cookie farm. Every time you buy a cookie farm, it costs you C cookies and gives you an extra F cookies per second.
Once you have X cookies that you haven't spent on farms, you win! Figure out how long it will take you to win if you use the best possible strategy.
Example
Suppose C=500.0, F=4.0 and X=2000.0. Here's how the best possible strategy plays out:
- You start with 0 cookies, but producing 2 cookies per second.
- After 250 seconds, you will have C=500 cookies and can buy a farm that producesF=4 cookies per second.
- After buying the farm, you have 0 cookies, and your total cookie production is 6 cookies per second.
- The next farm will cost 500 cookies, which you can buy after about 83.3333333seconds.
- After buying your second farm, you have 0 cookies, and your total cookie production is 10 cookies per second.
- Another farm will cost 500 cookies, while you can buy after 50 seconds.
- After buying your third farm, you have 0 cookies, and your total cookie production is 14 cookies per second.
- Another farm would cost 500 cookies, but it actually makes sense not to buy it: instead you can just wait until you have X=2000 cookies, which takes about142.8571429 seconds.
Total time: 250 + 83.3333333 + 50 + 142.8571429 = 526.1904762 seconds.
Notice that you get cookies continuously: so 0.1 seconds after the game starts you'll have 0.2 cookies, and π seconds after the game starts you'll have 2π cookies.
Input
The first line of the input gives the number of test cases, T. T lines follow. Each line contains three space-separated real-valued numbers: C, F and X, whose meanings are described earlier in the problem statement.
C, F and X will each consist of at least 1 digit followed by 1 decimal point followed by from 1 to 5 digits. There will be no leading zeroes.
Output
For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1) and y is the minimum number of seconds it takes before you can have X delicious cookies.
We recommend outputting y to 7 decimal places, but it is not required. y will be considered correct if it is close enough to the correct number: within an absolute or relative error of 10-6. See the FAQ for an explanation of what that means, and what formats of real numbers we accept.
Limits
1 ≤ T ≤ 100.
Small dataset
1 ≤ C ≤ 500.
1 ≤ F ≤ 4.
1 ≤ X ≤ 2000.
Large dataset
1 ≤ C ≤ 10000.
1 ≤ F ≤ 100.
1 ≤ X ≤ 100000.
Sample
Input
Output
4
30.0 1.0 2.0
30.0 2.0 100.0
30.50000 3.14159 1999.19990
500.0 4.0 2000.0
Case #1: 1.0000000
Case #2: 39.1666667
Case #3: 63.9680013
Case #4: 526.1904762
Note
Cookie Clicker was created by Orteil. Orteil does not endorse and has no involvement with Google Code Jam.
Google Code Jam 2014 资格赛:Problem B. Cookie Clicker Alpha的更多相关文章
- Google Code Jam 2014 资格赛:Problem D. Deceitful War
This problem is the hardest problem to understand in this round. If you are new to Code Jam, you sho ...
- Google Code Jam 2014 资格赛:Problem C. Minesweeper Master
Problem Minesweeper is a computer game that became popular in the 1980s, and is still included in so ...
- Google Code Jam 2014 Qualification 题解
拿下 ABD, 顺利晋级, 预赛的时候C没有仔细想,推荐C题,一个非常不错的构造题目! A Magic Trick 简单的题目来取得集合的交并 1: #include <iostream> ...
- Google Code Jam 2014 Round 1 A:Problem C. Proper Shuffle
Problem A permutation of size N is a sequence of N numbers, each between 0 and N-1, where each numbe ...
- Google Code Jam 2014 Round 1 A:Problem A Charging Chaos
Problem Shota the farmer has a problem. He has just moved into his newly built farmhouse, but it tur ...
- Google Code Jam 2014 Round 1 A:Problem B. Full Binary Tree
Problem A tree is a connected graph with no cycles. A rooted tree is a tree in which one special ver ...
- Google Code Jam 2014 Round 1B Problem B
二进制数位DP,涉及到数字的按位与操作. 查看官方解题报告 #include <cstdio> #include <cstdlib> #include <cstring& ...
- Google Code Jam 2014 总结
第一次参加ACM竞赛,对自己取得的成绩还满意. Round1A: Rank: 2446 Score: 9 (没有进前1000名,只能拼下次了) Round1B: Rank: 944 Score: 42 ...
- [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha
Problem B. Cookie Clicker Alpha Introduction Cookie Clicker is a Javascript game by Orteil, where ...
随机推荐
- skywalking学习
skywalking简介 SkyWalking一个开源可观测性平台,用于收集.分析.聚合和可视化来自服务和云原生基础设施的数据.SkyWalking提供了一种简单的方法,可以让你清晰的查看分布式系统. ...
- InputSplit—>RecordReder—>map(key,value,context)的过程解析
上图首先描述了在TaskTracker端Task(MapTask.ReduceTask)的执行过程,MapTask(org.apache.hadoop.mapred)首先被TaskRunner调用,然 ...
- 分享 | 自定义属于自己的U盘图标
文章目录 步骤 注意 想不想也可以自定义自己的U盘图标?其实,这并不难 步骤 在网上下载ICO格式的图标,也可以将自己喜欢的图片转换成ICO格式,并将图片命名为demo.ico: 点击这里打开记事本, ...
- PHP 让__get方法重新执行
<?php class A { public function __get($p) { echo "getting $p\r\n"; if(isset($this->$ ...
- SSMS查看表行数以及使用空间 How to show table row count and space used in SSMS - SSMS Tutorials
原文:How to show table row count and space used in SSMS - SSMS Tutorials There's a quick and convenien ...
- Webdriver如何启动不同浏览器(python)
WebDriver 支持 Firefox (FirefoxDriver).IE (InternetExplorerDriver).Opera (OperaDriver) 和 Chrome (Chrom ...
- Git 历险记(三)——创建一个自己的本地仓库
如果我们要把一个项目加入到Git的版本管理中,可以在项目所在的目录用git init命令建立一个空的本地仓库,然后再用git add命令把它们都加入到Git本地仓库的暂存区(stage or inde ...
- ES集群爆红,有未分配的片
curl GET http://192.168.46.166:9200/_cluster/health?level=indices curl -XPUT '192.168.46.166:9200/_c ...
- JStorm的搭建文档
1.下载jstorm的jar包 https://github.com/alibaba/jstorm/releases 2.解压jstorm的包 tar -xvf jstorm-2.4.0.tgz mv ...
- 2017.6.26 接口测试工具postman使用总结
参考来自: http://www.cnblogs.com/sunshine-sky66/p/6369963.html http://www.cnplugins.com/tool/specify-pos ...