Educational Codeforces Round 90 (Rated for Div. 2) A. Donut Shops(思维)

Donut Shops:

题目大意:(文末有原题)

有两种方案买甜甜圈:

  1. 每个a元
  2. 每盒b个c元;

给出a,b,c,输出 买多少个时,按方案1更划算,多少个时,按方案2更划算,如果不论多少个这个方案都不是更划算,就输出-1;

思路:

首先如果a > c的时候,按方案一肯定什么时候都不划算;

其次如果每盒平均下来的单价 (c / b) >= a 时,肯定按方案一都比较划算;

剩下的就是 平均单价 (c / b) < a 时,此时如果想要买的数量刚好是n盒,那肯定按盒买划算,否则就单个买划算;

代码:

#include <iostream>
using namespace std;
typedef long long ll;

ll a, b, c;

void solve() {
	cin >> a >> b >> c;
	if(a >= c) 
		cout << "-1 " << b << endl;
	else if(c / b >= a) 
		cout << "1 -1" << endl;
	else 
		cout << "1 " << b << endl;
}

int main() {
	int t;
	cin >> t;

	while(t--) {
		solve();
	}
	
	return 0;
}

原题:

题目:

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:

  1. how many donuts can you buy so that they are strictly cheaper in the first shop than in the second shop?
  2. 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 10^9. It can be shown that under the given constraints such values always exist if any values exist at all.

输入:

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≤10^9, 2≤b≤10^9, 1≤c≤10^9).

输出:

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 10^9.

If there is no such x, then print −1. If there are multiple answers, then print any of them.

样例:

Input:  

4
5 10 4
4 5 20
2 2 3
1000000000 1000000000 1000000000

Output:

-1 20
8 -1
1 2
-1 1000000000

Note:

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 10^9 donuts cost 10^18 dollars in the first shop and 10^9 dollars in the second shop.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"educational codeforces round 103 (rated for div. 2)"是一个Codeforces平台上的教育性比赛,专为2级选手设计评级。以下是有关该比赛的回答。 "educational codeforces round 103 (rated for div. 2)"是一场Codeforces平台上的教育性比赛。Codeforces是一个为程序员提供竞赛和评级的在线平台。这场比赛是专为2级选手设计的,这意味着它适合那些在算法和数据结构方面已经积累了一定经验的选手参与。 与其他Codeforces比赛一样,这场比赛将由多个问题组成,选手需要根据给定的问题描述和测试用例,编写程序来解决这些问题。比赛的时限通常有两到三个小时,选手需要在规定的时间内提交他们的解答。他们的程序将在Codeforces的在线评测系统上运行,并根据程序的正确性和效率进行评分。 该比赛被称为"educational",意味着比赛的目的是教育性的,而不是针对专业的竞争性。这种教育性比赛为选手提供了一个学习和提高他们编程技能的机会。即使选手没有在比赛中获得很高的排名,他们也可以从其他选手的解决方案中学习,并通过参与讨论获得更多的知识。 参加"educational codeforces round 103 (rated for div. 2)"对于2级选手来说是很有意义的。他们可以通过解决难度适中的问题来测试和巩固他们的算法和编程技巧。另外,这种比赛对于提高解决问题能力,锻炼思维和提高团队合作能力也是非常有帮助的。 总的来说,"educational codeforces round 103 (rated for div. 2)"是一场为2级选手设计的教育性比赛,旨在提高他们的编程技能和算法能力。参与这样的比赛可以为选手提供学习和进步的机会,同时也促进了编程社区的交流与合作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值