列表

详情


NC223903. ACoronaVirusTesting

描述

Testing for Corona can be done individually, e.g., 100 people require 100 test kits. Alternatively, the test can be done in groups (pools), e.g., 100 people can be divided into five group of 20 people each and then using only one test kid per group. If one or more groups test positive, then individual tests are needed for each person in those group. So, for our example, five groups will need 5 test kits and let’s say two groups test positive, so we would need additional 40 (2*20) test kits for a total of 45 (5+40) test kits.

The Problem:

Given the data for the two possible testing approaches, determine which approach will use fewer test kits.

输入描述

There is only one input line; it provides three integers:g(2 ≤g≤ 50), indicating the number of groups,p(2 ≤p≤ 50), indicating the number of people in each group, andt(0 ≤t≤g), indicating how many groups tested positive (i.e., people in these groups need to be tested individually).

输出描述

Print 1 (one) if testing everyone individually will use fewer kits, 2 (two) if testing in groups will use fewer kits, and 0 (zero) if the two approaches use the same number of kits.

示例1

输入:

40 3 38

输出:

1

示例2

输入:

10 20 2

输出:

2

示例3

输入:

20 10 18

输出:

0

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++ 解法, 执行用时: 3ms, 内存消耗: 428K, 提交时间: 2021-08-17 12:04:08

#include <cstdio>
int g, p, t;
int main()
{
	scanf("%d%d%d", &g, &p, &t);
	int a=g+p*t, b=g*p;
	printf("%d\n", a==b?0:a>b?1:2);
	return 0;
}

Pascal 解法, 执行用时: 5ms, 内存消耗: 256K, 提交时间: 2021-08-17 12:13:02

var g,p,t:longint;
begin
read(g,p,t);
if g*p<p*t+g then write(1)
    else if p*t+g<g*p then write(2)
        else write(0);
end.

Python3 解法, 执行用时: 61ms, 内存消耗: 7020K, 提交时间: 2021-08-17 20:35:49

a, b, c = map(int, input().split())
if a + b * c > a * b:
    print(1)
elif a + b * c == a * b:
    print(0)
else:
    print(2)

上一题