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:

  1. You start with 0 cookies, but producing 2 cookies per second.
  2. After 250 seconds, you will have C=500 cookies and can buy a farm that producesF=4 cookies per second.
  3. After buying the farm, you have 0 cookies, and your total cookie production is 6 cookies per second.
  4. The next farm will cost 500 cookies, which you can buy after about 83.3333333seconds.
  5. After buying your second farm, you have 0 cookies, and your total cookie production is 10 cookies per second.
  6. Another farm will cost 500 cookies, while you can buy after 50 seconds.
  7. After buying your third farm, you have 0 cookies, and your total cookie production is 14 cookies per second.
  8. 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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Google Code Jam 2014 Qualification 题解

    拿下 ABD, 顺利晋级, 预赛的时候C没有仔细想,推荐C题,一个非常不错的构造题目! A Magic Trick 简单的题目来取得集合的交并 1: #include <iostream> ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Google Code Jam 2014 Round 1B Problem B

    二进制数位DP,涉及到数字的按位与操作. 查看官方解题报告 #include <cstdio> #include <cstdlib> #include <cstring& ...

  8. Google Code Jam 2014 总结

    第一次参加ACM竞赛,对自己取得的成绩还满意. Round1A: Rank: 2446 Score: 9 (没有进前1000名,只能拼下次了) Round1B: Rank: 944 Score: 42 ...

  9. [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 ...

随机推荐

  1. luogu P3819 松江1843路

    题目描述 涞坊路是一条长L米的道路,道路上的坐标范围从0到L,路上有N座房子,第i座房子建在坐标为x[i]的地方,其中住了r[i]人. 松江1843路公交车要在这条路上建一个公交站,市政府希望让最多的 ...

  2. iOS9 Storyboard unwind segue反回传递事件时机详细步骤

    当返回上一个界面且需要上一个界面做某事时,用unwind segue实现起来比delegate简单许多,甚至有时不适合用delegate来实现,那么我们就用unwind segue吧,而且像1-> ...

  3. sourceinsight----tabsiplus颜色配置文件

    参考: http://blog.csdn.net/orbit/article/details/7585607 下面是我的颜色配置 http://files.cnblogs.com/pengdongli ...

  4. DOM系统学习-基础

    DOM介绍  DOM介绍: D 网页文档 O 对象,可以调用属性和方法 M 网页文档的树型结构  节点: DOM将树型结构理解为由节点组成.     节点种类: 元素节点.文本节点.属性节点等 查找元 ...

  5. IntelliJ IDEA 配合 Maven 的一些技巧:Profiles

    环境 IntelliJ IDEA 2017.1 Maven 3.3.9 Nexus 3.2.1 学习前提 了解 Maven 配置的基本用法 了解私有仓库,比如 nexus 的一些概念 强烈建议把 Ma ...

  6. 浅谈Java中静态初始化块跟非初始化块

    众所周知在JAVA编程语言中有两种初始化块:   静态初始化块 非静态初始化块 他们到底有什么区别呢?今天就浅谈一下JAVA中静态初始化块和非静态初始化块的区别   静态初始化块 定义:       ...

  7. Python 最火 IDE 最受欢迎(转载)

    来自:开源中国社区 链接:https://www.oschina.net/news/86973/packt-skill-up-2017 电子书网站 Packt 刚刚发布了第三届 “Skill UP” ...

  8. 软件测试技术---Web应用软件测试

    从测试的角度看,Web应用软件的以下特点会导致Web应用软件的测试有别于其他软件的测试 1.基于无连接协议 2.内容驱动 3.开发周期短 4.演化频繁 5.安全性要求较高 6.美观性要求较高 Web应 ...

  9. Centos 7 联想Y430P无线网卡驱动安装 过程参考

    Centos 7  联想Y430P无线网卡驱动安装 过程参考 ABRT 已检测到 [root@endv ~]# yum install -y rdesktop 已加载插件:fastestmirror, ...

  10. jQuery的DOM操作之加入元素和删除元素

    加入元素: .append()--在目标元素之后加入元素. .prepend()--在目标元素之前加入元素. .after()--在目标元素之后换行加入元素: .before()--在目标元素之前加入 ...