CF1373A.Donut Shops
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are two rival donut shops.
The first shop sells donuts at retail: each donut costs a dollars.
The second shop sells donuts only in bulk: box of b donuts costs c dollars. So if you want to buy x donuts from this shop, then you have to buy the smallest number of boxes such that the total number of donuts in them is greater or equal to x.
You want to determine two positive integer values:
- how many donuts can you buy so that they are strictly cheaper in the first shop than in the second shop?
- how many donuts can you buy so that they are strictly cheaper in the second shop than in the first shop?
If any of these values doesn't exist then that value should be equal to −1. If there are multiple possible answers, then print any of them.
The printed values should be less or equal to 109. It can be shown that under the given constraints such values always exist if any values exist at all.
有两家竞争的甜甜圈店。
第一家店以零售方式出售甜甜圈:每个甜甜圈售价为 a 美元。
第二家店仅以批发方式出售甜甜圈:每盒含 b 个甜甜圈,售价为 c 美元。因此,若你想从该店购买 x 个甜甜圈,则必须购买最小数量的盒子,使得这些盒子中甜甜圈的总数大于或等于 x。
你需要确定两个正整数:
- 购买多少个甜甜圈时,在第一家店购买严格比在第二家店购买更便宜?
- 购买多少个甜甜圈时,在第二家店购买严格比在第一家店购买更便宜?
如果其中任一值不存在,则该值应为 −1。若存在多个可能的答案,输出任意一个即可。
所输出的值必须小于或等于 109。可以证明:在给定约束条件下,只要存在满足条件的值,就一定存在不超过 109 的解。
输入格式
The first line contains a single integer t (1≤t≤1000) — the number of testcases.
Each of the next t lines contains three integers a, b and c (1≤a≤109, 2≤b≤109, 1≤c≤109).
第一行包含一个整数 t(1≤t≤1000)—— 表示测试用例的数量。
接下来的 t 行中,每行包含三个整数 a、b 和 c(1≤a≤109,2≤b≤109,1≤c≤109)。
输出格式
For each testcase print two positive integers. For both shops print such x that buying x donuts in this shop is strictly cheaper than buying x donuts in the other shop. x should be greater than 0 and less or equal to 109.
If there is no such x, then print −1. If there are multiple answers, then print any of them.
对每个测试用例,输出两个正整数。对两家商店分别输出一个满足如下条件的 x:在该商店购买 x 个甜甜圈的价格严格低于在另一家商店购买 x 个甜甜圈的价格。x 应满足大于 0 且小于等于 109。
若不存在这样的 x,则输出 −1。若存在多个满足条件的 x,则输出任意一个即可。
输入输出样例
输入#1
4 5 10 4 4 5 20 2 2 3 1000000000 1000000000 1000000000
输出#1
-1 20 8 -1 1 2 -1 1000000000
说明/提示
In the first testcase buying any number of donuts will be cheaper in the second shop. For example, for 3 or 5 donuts you'll have to buy a box of 10 donuts for 4 dollars. 3 or 5 donuts in the first shop would cost you 15 or 25 dollars, respectively, however. For 20 donuts you'll have to buy two boxes for 8 dollars total. Note that 3 and 5 are also valid answers for the second shop, along with many other answers.
In the second testcase buying any number of donuts will be either cheaper in the first shop or the same price. 8 donuts cost 32 dollars in the first shop and 40 dollars in the second shop (because you have to buy two boxes). 10 donuts will cost 40 dollars in both shops, so 10 is not a valid answer for any of the shops.
In the third testcase 1 donut costs 2 and 3 dollars, respectively. 2 donuts cost 4 and 3 dollars. Thus, 1 is a valid answer for the first shop and 2 is a valid answer for the second shop.
In the fourth testcase 109 donuts cost 1018 dollars in the first shop and 109 dollars in the second shop.
在第一个测试用例中,在第二家店购买任意数量的甜甜圈都更便宜。例如,购买 3 个或 5 个甜甜圈时,你必须购买一盒 10 个的甜甜圈,花费 4 美元。而在第一家店,3 个或 5 个甜甜圈分别需花费 15 美元或 25 美元。对于 20 个甜甜圈,你必须购买两盒,总共花费 8 美元。注意,除了许多其他答案外,3 和 5 也是第二家店的有效答案。
在第二个测试用例中,在第一家店购买任意数量的甜甜圈都更便宜或价格相同。8 个甜甜圈在第一家店花费 32 美元,在第二家店花费 40 美元(因为你必须购买两盒)。10 个甜甜圈在两家店均花费 40 美元,因此 10 对任何一家店都不是有效答案。
在第三个测试用例中,1 个甜甜圈的价格分别为 2 美元和 3 美元;2 个甜甜圈的价格分别为 4 美元和 3 美元。因此,1 是第一家店的有效答案,而 2 是第二家店的有效答案。
在第四个测试用例中,109 个甜甜圈在第一家店花费 1018 美元,在第二家店花费 109 美元。
输入解题思路,AI测评打分。不知道怎么写?