Google Code Jam 2010 Round 1C Problem B. Load Testing
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, T. T lines follow, each of which contains space-separated integers L, P 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.
L, P and C are all integers.
Small dataset
1 ≤ L < P ≤ 103.
Large dataset
1 ≤ L < P ≤ 109.
Sample
Input |
Output |
4 |
Case #1: 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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Google Code Jam 2016 Round 1B Problem C. Technobabble
题目链接:https://code.google.com/codejam/contest/11254486/dashboard#s=p2 大意是教授的学生每个人在纸条上写一个自己的topic,每个to ...
- 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. ...
- Google Code Jam 2016 Round 1C C
题意:三种物品分别有a b c个(a<=b<=c),现在每种物品各选一个进行组合.要求每种最和最多出现一次.且要求任意两个物品的组合在所有三个物品组合中的出现总次数不能超过n. 要求给出一 ...
随机推荐
- Java正则表达式的最简单应用
String emailRegex = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; Pattern pat = ...
- POJ 3083
---恢复内容开始--- http://poj.org/problem?id=3083 题目大意就是给你要你从S走到E,且只有.代表的地方才是可以走的,有三种方式的走法. 一.是向左优先转,从S到E的 ...
- 无论IT代码系统还是人生都是有惯性的
是的,这和IT系统和代码没有什么关系:鸡汤式的文章,看烦了的就关掉吧,想看的请听我碎碎念.惯性本是物理学研究的问题,这里没有要研究物理学里的惯性.惯性无时无刻地发生在我们的日常生活中,只是你我都没有察 ...
- mybatis前台传给带年月日时分秒的数据给后台,后台接收不到时分秒
框架spring+springMVC+mybatis, 前台给后台传数据传不了时分秒,所以用springMVC的注解解决了,记录一下 controller中如下: /** * * 方法描述 : 使用@ ...
- Extjs给gridPanel添加单价双击事件和获取当前行的数据
有两个小属性,如下 this.on('rowdblclick', this.readContent, this); this.on('cellclick', this.gridCellClick, t ...
- Ubuntu 更新源
1.首先备份Ubuntu12.04源列表 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup (备份下当前的源列表) 2.修改更新源 ...
- 引水入城(codevs 1066)
题目描述 Description 在一个遥远的国度,一侧是风景秀美的湖泊,另一侧则是漫无边际的沙漠.该国的行政 区划十分特殊,刚好构成一个N行M列的矩形,如上图所示,其中每个格子都代表一座城 市,每座 ...
- Linux 底下使用C 对文件进行遍历
#include <stdio.h>#include <stdlib.h>main (int argc,char *argv[]){char ch;FILE *fp;int i ...
- php 面向对象之继承、多态和静态方法
<?php //继承:子类可以继承父类的一切 //特点:单继承 //父类 class Ren { public $name; public $sex; public $yuyan; functi ...
- 禁随意改root密码
lsattr 主要参数如表. -a 显示所有文件和目录,包括以"."为名称开头字符的额外内建,现行目录"."与上层目录"..". -d 显示 ...