题目描述
There are two rival donut shops.

The first shop sells donuts at retail: each donut costs aa dollars.

The second shop sells donuts only in bulk: box of bb donuts costs cc dollars. So if you want to buy xx 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 xx .

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−1 . If there are multiple possible answers, then print any of them.

The printed values should be less or equal to 10^910
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 tt ( 1 \le t \le 10001≤t≤1000 ) — the number of testcases.

Each of the next tt lines contains three integers aa , bb and cc ( 1 \le a \le 10^91≤a≤10
9
, 2 \le b \le 10^92≤b≤10
9
, 1 \le c \le 10^91≤c≤10
9
).

输出格式
For each testcase print two positive integers. For both shops print such xx that buying xx donuts in this shop is strictly cheaper than buying xx donuts in the other shop. xx should be greater than 00 and less or equal to 10^910
9
.

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

题意翻译
有两个甜甜圈店。

第一家店零售甜甜圈:每个甜甜圈的价格为 aa 美元。

第二家店散装出售甜甜圈:一盒 bb 个甜甜圈的价格为 cc 美元。 只能整盒买。

在第一家商店中购买几个甜甜圈比在第二家商店中便宜?

在第二家商店中购买几个甜甜圈比在第一家商店中便宜?

如果其中某个答案不存在,输出 -1−1。 如果有多个可能的答案,请输出任意一个。

输出的值应 \leq 10^9≤10
9
。 可以证明,如果存在答案,那么在 10^910
9
内也必定存在答案。

输入输出样例
输入 #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 33 or 55 donuts you’ll have to buy a box of 1010 donuts for 44 dollars. 33 or 55 donuts in the first shop would cost you 1515 or 2525 dollars, respectively, however. For 2020 donuts you’ll have to buy two boxes for 88 dollars total. Note that 33 and 55 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. 88 donuts cost 3232 dollars in the first shop and 4040 dollars in the second shop (because you have to buy two boxes). 1010 donuts will cost 4040 dollars in both shops, so 1010 is not a valid answer for any of the shops.

In the third testcase 11 donut costs 22 and 33 dollars, respectively. 22 donuts cost 44 and 33 dollars. Thus, 11 is a valid answer for the first shop and 22 is a valid answer for the second shop.

In the fourth testcase 10^910
9
donuts cost 10^{18}10
18
dollars in the first shop and 10^910
9
dollars in the second shop.

思路
两次a的操作等于一次b的操作,那么就看是两次a的花费高还是一次b的花费高
如果a+a高,就尽量多用b,那就先用b使min(x,y)等于0,然后再使abs(x-y)就是剩余的另一个数,再用a 使它等于0;
如果b高,就全用a,(x+y)次a的操作

代码

#include<bits/stdc++.h>
using namespace std;
int main()
{long long int t,a,b,x,y;cin>>t;while(t--){cin>>x>>y>>a>>b;if(a+a<=b){cout<<abs(x+y)*a<<endl;}else{cout<<min(x,y)*b+abs(x-y)*a<<endl;}}return 0;
}

CF1373A Donut Shops相关推荐

  1. Educational Codeforces Round 90 (Rated for Div. 2) A. Donut Shops (1000)

    1373A - Donut Shops 题意&&思路: if(a<c)cout<<1; else cout<<-1;if(a*b>c)cout< ...

  2. A. Donut Shops

    int main(){IOS;rush(){ll a,b,c;cin>>a>>b>>c;if(a>=c) cout<<-1<<&quo ...

  3. A. Donut Shops(分类模拟)

    这 题 相 信 大 家 都 能 切 出 来 , 但 是 得 讲 究 分 类 , 快 且 准 确 这题相信大家都能切出来,但是得讲究分类,快且准确 这题相信大家都能切出来,但是得讲究分类,快且准确 Ⅰ ...

  4. Educational Codeforces Round 90 (Rated for Div. 2)部分题解

    A - Donut Shops 题解: 1.我们首先特判一下包装盒里面只有一个物品的情况,如果只装了一个物品,那我们就直接比较这两个物品的单价即可. 2.如果盒子里面装的不止是一键物品,那么我们就需要 ...

  5. Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)

    Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...

  6. JavaScript正则式练习

    使用正则式匹配第一个数字和最后一个数字,使用环视 str2 = 09051 : Fast Food Restaurants - Concession Stands/Snack Bars Delicat ...

  7. GIS基础软件及操作(一)

    GIS基础软件及操作(一) 原文  GIS基础软件及操作(一) 练习一.浏览地理数据 使用 ArcGIS浏览地理数据 第1步 启动 ArcMap 启动ArcMap.执行菜单命令:开始>>所 ...

  8. CodeForces - 1373

    CodeForces - 1373 A - Donut Shops 买1个的时候,店2最亏,店1最有可能比店2便宜 买b个的时候,店2最赚,店2最有可能比店1便宜 比较这两种情况即可ll a,b,c; ...

  9. 助记词转换工具_有助于大流行的10种翻译工具

    助记词转换工具 With social distancing to keep us at arm's length from strangers, no traveling, and a scarci ...

最新文章

  1. 清华大学:智能驾驶背景下转向系统发展趋势
  2. 【Android 逆向】APK 文件格式 ( Android 应用安装 | Zip 文件格式 | 使用 Python 代码提取 APK 文件 )
  3. DSP与FPGA和嵌入式是什么关系?
  4. 清华团队最新成果:可致特朗普能咏比特币,AI写古诗“更上一层楼”
  5. chrome浏览器中遇到bug【Error in event handler: TypeError: Cannot read property 'name' of undefined】
  6. lombok进行有参无参构造出现的问题
  7. [密码学基础][每个信息安全博士生应该知道的52件事][Bristol Cryptography][第16篇]描述DSA、Schnorr和RSA-FDH的密钥生成、签名和验证算法。
  8. 智能化服务器怎么调,怎么设置dns 智能dns设置方法 【图文】
  9. Ubuntu16.04 安装Tensorflow-CPU
  10. 分享几个简单易做的Java小程序,一起动手来试试吧
  11. 学成在线 网页前端(源码DIV+CSS)
  12. MFC框架学习:《深入浅出MFC》阅读笔记
  13. Jetson Nano python中文语音播报数字距离 基于pyttsx3
  14. 小程序 学习。。。[个人感觉吧 官方文档写的相当详细了。。]
  15. ubuntu java 7_在Ubuntu上安装Java 7
  16. MPC-HC视频播放器
  17. java 自旋锁实现
  18. 大型破碎设备之颚式破碎机简介
  19. 黑帽seo收徒之 微信视频号创作 变现
  20. Everything Is Generated In Equal Probability HDU-6595 期望DP

热门文章

  1. 【厚积薄发】CSV配置文件的优化策略
  2. 树莓派4B分辨率设置
  3. python map函数详解
  4. su highgo可能引起的psql报错
  5. matlab 读取图片的格式
  6. 为何“迷你本”退货率很高?
  7. test 190802 生日蛋糕
  8. ftp匿名用户匿名用户本地用户设置
  9. 页面中实现轮播图效果
  10. 宝甄携手叶小鹏赋予工艺夺目动人色彩