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. 要求给出一 ...
随机推荐
- mysql中binary相加的问题
我在mysql中有这样一段代码 SQL code ? 1 2 3 4 5 6 7 8 declare @byte1 binary(1) declare @byte2 binary(1) decla ...
- xenomai安装
一.Linux内核打实时补丁 1.将下载的Linux和xenomai安装包放在/usr/src目录下,并解压文件包,命令如下 tar xjf Linux-3.8.13.tar.bz2 tar x ...
- bat批量去除文件首行和合并到文件
bat批量去除文件首行 set n=1 :starline for %%j in (*.txt) do ( :3 if exist D:\work\test\new_%n%.txt (set /a n ...
- nginx服务器的网站权限问题
有时候我们的网站根目录会从一个目录迁移到另一个目录,如果我们服务器使用的是nginx或者Apache,我们一般会配置好网站根目录后然后往直接把网站解压或者上传到根目录中,这样引起的问题是无法对对文件进 ...
- MVC增删改查例子
一.显示用户列表1.新建UserInfoController控制器 public ActionResult Index() { DataTable table = SQLHelper.ExecuteR ...
- 何时使用hadoop fs、hadoop dfs与hdfs dfs命令(转)
hadoop fs:使用面最广,可以操作任何文件系统. hadoop dfs与hdfs dfs:只能操作HDFS文件系统相关(包括与Local FS间的操作),前者已经Deprecated,一般使用后 ...
- 在qq中可以使用添加标签功能
而在sina中不可以,现在就保持一致吧!那么每天使用的日志主要是记录工作项目上的问题还有生活的感受
- Linux下的原子操作
linux支持的哪些操作是具有原子特性的?知道这些东西是理解和设计无锁化编程算法的基础. __sync_fetch_and_add系列的命令,发现这个系列命令讲的最好的一篇文章,英文好的同学可以直接去 ...
- ***阿里云linux 下怎么配置虚拟主机
最近有个问题,本人在阿里云买了linux服务器,用wordpress做了一个博客网站www.bravetiger.cn,现在想加一个电商系统进去,假设二级域名为:shop.bravetiger.cn, ...
- 如何开启PostGreSQL的远程访问端口?
用以下办法即可: postgresql默认情况下,远程访问不能成功,如果需要允许远程访问,需要修改两个配置文件,说明如下: 1.postgresql.conf 将该文件中的listen_address ...