https://code.google.com/codejam/contest/619102/dashboard#s=p1&a=1

Problem

Now that you have won Code Jam and been hired by Google as a software engineer, you have been assigned to work on their wildly popular programming contest website.

Google is expecting a lot of participants (P) in Code Jam next year, and they want to make sure that the site can support that many people at the same time. During Code Jam 2010 you learned that the site could support at least L people at a time without any errors, but you also know that the site can't yet support P people.

To determine how many more machines you'll need, you want to know within a factor of Chow many people the site can support. This means that there is an integer a such that you know the site can support a people, but you know the site can't support a * C people.

You can run a series of load tests, each of which will determine whether the site can support at least X people for some integer value of X that you choose. If you pick an optimal strategy, choosing what tests to run based on the results of previous tests, how many load tests do you need in the worst case?

Input

The first line of the input gives the number of test cases, TT lines follow, each of which contains space-separated integers LP and C in that order.

Output

For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is the number of load tests you need to run in the worst case before knowing within a factor of C how many people the site can support.

Limits

1 ≤ T ≤ 1000.
2 ≤ C ≤ 10.
LP and C are all integers.

Small dataset

1 ≤ L < P ≤ 103.

Large dataset

1 ≤ L < P ≤ 109.

Sample

Input 
 
Output 
 
4
50 700 2
19 57 3
1 1000 2
24 97 2
Case #1: 2
Case #2: 0
Case #3: 4
Case #4: 2

Explanation

In Case #2, we already know that the site can support between 19 and 57 people. Since those are a factor of 3 apart, we don't need to do any testing.

In Case #4, we can test 48; but if the site can support 48 people, we need more testing, because 48*2 < 97. We could test 49; but if the site can't support 49 people, we need more testing, because 24 * 2 < 49. So we need two tests.

Solution:

int solve(int L, int P, int C)
{
int tries = ;
for (;;) {
if (L * pow(C, pow(, tries)) >= P) {
return tries;
}
tries++;
}
} int main()
{
freopen("in.in", "r", stdin);
freopen("out.out", "w", stdout); int T;
scanf("%d\n", &T);
if (!T) {
cerr << "Check input!" << endl;
exit();
} for (int t = ; t <= T; t++) {
cerr << "solving: #" << t << " / " << T << endl; int L, P, C;
scanf("%d %d %d\n", &L, &P, &C);
auto result = solve(L, P, C);
printf("Case #%d: %d\n", t, result);
} fclose(stdin);
fclose(stdout);
return ;
}

Google Code Jam 2010 Round 1C Problem B. Load Testing的更多相关文章

  1. Google Code Jam 2010 Round 1C Problem A. Rope Intranet

    Google Code Jam 2010 Round 1C Problem A. Rope Intranet https://code.google.com/codejam/contest/61910 ...

  2. Google Code Jam 2010 Round 1A Problem A. Rotate

    https://code.google.com/codejam/contest/544101/dashboard#s=p0     Problem In the exciting game of Jo ...

  3. Google Code Jam 2010 Round 1B Problem B. Picking Up Chicks

    https://code.google.com/codejam/contest/635101/dashboard#s=p1   Problem A flock of chickens are runn ...

  4. Google Code Jam 2010 Round 1B Problem A. File Fix-it

    https://code.google.com/codejam/contest/635101/dashboard#s=p0   Problem On Unix computers, data is s ...

  5. dp - Google Code jam Qualification Round 2015 --- Problem B. Infinite House of Pancakes

    Problem B. Infinite House of Pancakes Problem's Link:   https://code.google.com/codejam/contest/6224 ...

  6. Google Code jam Qualification Round 2015 --- Problem A. Standing Ovation

    Problem A. Standing Ovation Problem's Link:   https://code.google.com/codejam/contest/6224486/dashbo ...

  7. Google Code Jam 2016 Round 1B Problem C. Technobabble

    题目链接:https://code.google.com/codejam/contest/11254486/dashboard#s=p2 大意是教授的学生每个人在纸条上写一个自己的topic,每个to ...

  8. Google Code Jam 2009, Round 1C C. Bribe the Prisoners (记忆化dp)

    Problem In a kingdom there are prison cells (numbered 1 to P) built to form a straight line segment. ...

  9. Google Code Jam 2016 Round 1C C

    题意:三种物品分别有a b c个(a<=b<=c),现在每种物品各选一个进行组合.要求每种最和最多出现一次.且要求任意两个物品的组合在所有三个物品组合中的出现总次数不能超过n. 要求给出一 ...

随机推荐

  1. Linux 系统安全 抵御TCP的洪水

    抵御TCP的洪水 分类: LINUX tcp_syn_retries :INTEGER默认值是5对 于一个新建连接,内核要发送多少个 SYN 连接请求才决定放弃.不应该大于255,默认值是5,对应于1 ...

  2. php中global与$GLOBALS的用法及区别

    php中global 与 $GLOBALS[""] 差别 原本觉得global和$GLOBALS除了写法不一样觉得,其他都一样,可是在实际利用中发现2者的差别还是很大的! 先看下面 ...

  3. 【OpenStack】OpenStack系列3之Swift详解

    Swift安装部署(与keystone依赖包有冲突,需要安装不同版本eventlet) 参考:http://www.server110.com/openstack/201402/6662.html h ...

  4. 【SpringMVC】SpringMVC系列5之@RequestHeader 映射请求头属性值

    5.@RequestHeader 映射请求头属性值 5.1.概述 请求头包含了若干个属性,服务器可据此获知客户端的信息,通过 @RequestHeader 即可将请求头中的属性值绑定到处理方法的入参中 ...

  5. Hydra---Linux下的暴力美学

    引自:http://www.cnblogs.com/mchina/archive/2013/01/01/2840815.html 安装:http://www.91ri.org/2867.html yu ...

  6. C#模拟百度登录

    目录: 1.fiddler解析百度登录地址 2.处理传入参数 1.fiddler解析百度登录地址 因工作需要,所以研究了下百度的登陆.首先打开https://passport.baidu.com/v2 ...

  7. 利用FFmpeg生成视频缩略图 2.1.8

    1.下载FFmpeg文件包,解压包里的\bin\下的文件解压到 D:\ffmpeg\ 目录下. 下载地址 http://ffmpeg.zeranoe.com/builds/win32/static/ ...

  8. mongodb数据结构学习1--增删改查

    插入文档 在数据库中,数据插入是最基本的操作,在MongoDB使用db.collection.insert(document)语句来插入文档: document是文档数据,collection是存放文 ...

  9. 获取Assets目录下的图片并显示

    package com.jingle.getlocal; import java.io.InputStream; import android.app.Activity; import android ...

  10. 菜鸟学Linux命令:bg fg jobs命令 任务管理

    jobs命令 jobs命令用于查看当前终端后台运行的任务 注意和ps的区别: ps命令用于查看瞬间进程的动态 通过一个实例可以理解它们之间的区别,依次执行如下命令:vim & //后台执行vi ...