UVa 12502 Three Families:想法题

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=3946

哈哈。考想法的一道题。

首先注意到这句话:You may assume both families were cleaning at the same speed.

所以按理来说,(样例1中)本应该周末每个家庭都花3小时来清理花园,但A在忙完自己的一部分后又帮了C2小时,B帮了C1小时所以A要得90*2/(2+1)=60美刀

完整代码:

/*0.019s*/

#include<cstdio>

int main()
{
	int t, a, b, m;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d%d%d", &a, &b, &m);
		printf("%d\n", m * (2 * a - b) / (a + b));
	}
	return 0;
}

查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索scanf
, http
小时
ora 12502、tns 12502、12502、three.js、three,以便于您获取更多的相关知识。

时间: 2024-12-09 08:17:08

UVa 12502 Three Families:想法题的相关文章

UVa 10132 File Fragmentation (想法题)

10132 - File Fragmentation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1073 Your friend, a biochemistry major, tripped while carrying a tray of compu

UVa 12004 Bubble Sort:想法题

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3155 枚举交换次数算期望太麻烦,不妨换个思路:对于任意一对数字,它们之间发生交换的概率和不交换的概率是相等的,那这对数字提供的期望值就为1/2.总共有C(n,2)对数字,所以最终的期望值就为n*(n-1)/4 完整代码: 01./*0.015s*/ 02. 03.#include<cs

UVa 105 The Skyline Problem (想法题)

105 - The Skyline Problem Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=41 这题有个很巧的思路:离散化. 什么意思呢?既然每栋大楼的高和左右边界都是整数,那么不妨把线段用一个个整点表示.既然最后只求一个轮廓,那么对每个横坐标,就记

UVa 10152 ShellSort (想法题)

10152 - ShellSort Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=103&page=show_problem&problem=1093 He made each turtle stand on another one's back And he piled them all up in a nine

UVa 10795 A Different Task:汉诺塔&amp;amp;想法题

10795 - A Different Task Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=1736 The (Three peg) Tower of Hanoi problem is a popular one in computer science

CERC 2004 / UVa 1335 Beijing Guards:二分&amp;amp;贪心&amp;amp;想法题

1335 - Beijing Guards Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=4081 Beijing was once surrounded by four rings of city walls: the Forbidden City Wa

UVa 571 Jugs (想法题)

571 - Jugs Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=512 思路: 由于是special judge,所以构造出一个可行解就可以. 论断:如果A是空的就加水,不空就向B倒,B满了之后就empty掉,这样在B中一定可以形成0~B的任意一个解.

UVa 10025 The ? 1 ? 2 ? ... ? n = k problem:数学&amp;amp;想法题&amp;amp;常数算法

10025 - The ? 1 ? 2 ? ... ? n = k problem Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem&problem=966 The problem Given the following formula, one can set operato

UVa 757 / POJ 1042 Gone Fishing: 枚举&amp;amp;贪心&amp;amp;想法题&amp;amp;优先队列

757 - Gone Fishing Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=698 http://poj.org/problem?id=1042 John is going on a fishing trip. He has h hours available ( ), and t