A. 采购
问题描述
作为资深宅男,嘉娃醒着的时候就坐在电脑前。为了提高宅的效率,他连下楼吃饭
的时间都不放过了。于是他需要每隔一段时间去超市进行一次大采购来保证有充足的
食物储备。
嘉娃的学校里有两家超市,嘉娃每次只能去一家超市采购。为了省钱买点卡,嘉娃
搞到了一份两家超市的物价表。不过嘉娃不想在算帐上浪费时间,现在他给了你一份
他的购物清单,你能帮助嘉娃算出去哪家超市购物便宜吗?
输入格式
第一行一个整数 N (0 ≤ N ≤ 1000),表示嘉娃要买多少种物品。
下面共 2N 行。第 2i 行包含一个字符串 si ,表示第 i 件商品的名称,和一个整数
di (1 ≤ di ≤ 30),表示嘉娃要购买第 i 件商品的数量, si 和 di 之间以一个空格分开。
si 的长度至少为 1 且不超过 8,并且 si 仅由小写字母组成。第 2i + 1 行包含两个整数
ai 和 bi ,分别表示第 i 件商品在超市 A 和超市 B 的售价 (0 ≤ ai , bi ≤ 100)。
输出格式
如果超市 A 的价格比超市 B 便宜,则输出一行"I like A!"。如果超市 B 的价格低,
则输出一行"I like B!"。如果在两家超市的花费一样,则输出一行"I like both!"。
输出不包含引号。
样例输入
3
baozi 30
50 55
paomian 30
55 50
wan 1
100 98
样例输出
I like B!
#include<cstdio>
int main(){
int n;
int m;
int a=0,b=0;
int rA=0,rB=0;
char str[1000];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%s",str);
scanf("%d",&m);
scanf("%d%d",&a,&b);
rA+=m*a;
rB+=m*b;
}
if(rA>rB){
printf("I like B!\n");
}else if(rA<rB){
printf("I like A!\n");
}else{
printf("I like both!\n");
}
return 0;
}
分享到:
相关推荐
计算机网络:自顶向下方法第8版,Global版
A Guide to SQL, 8th Edition
A First Course In Probability 8th
书是英文原版,里面有源码,很清楚,比市面上其他书好太多,以动手编程为导向,而不是各种抽象概念。用最简单基本的方法,实现C++的快速入门,文件夹中有部分更新的文件以及源码
Understanding Automotive Electronics 8th Appendix A - The Systems Approach to Control and Instrumentation
Learn Java GUI Applications A JFC Swing Tutorial(8th) 英文azw3 第8版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
英文版概率论第八版,经典教材,可与已上传的中文版结合使用,PDF,解压即可
Calculus: A Complete Course, Eighth Edition 版本 with MyMathLab (8th Edition 版本) By 作者: Robert A. Adams – Christopher Essex ISBN-10 书号: 0321880218 ISBN-13 书号:: 9780321880215 Edition 版本: 8 ...
Asking the Right Questions, A Guide to Critical Thinking, 8th Ed
For almost three decades, Roger Pressman's "Software Engineering: A Practitioner's Approach" has been the world's leading textbook in software engineering. The new seventh edition represents a major ...
become proficient Java programmers A brief version Introduction to Java Programming Brief Version Eighth Edition is available for a first course on programming commonly known as CS1 The brief version ...
作者是Roger S.Pressman 分五部分来介绍和学习软件工程,第五部分为高级课题:包括了形式化方法、软件复用、再工程、客户/服务器软件工程、计算机辅助软件工程
书籍列表: Computer Systems - A Programmer's Perspective.pdf Design of the Unix Operating System By Maurice Bach.pdf ...附百度云下载链接:https://pan.baidu.com/s/15QrbxQqt-A_mkb4EHGfovA
C How to Program is a comprehensive introduction to programming in C. Like other texts of the Deitels’ How to Program series, the book serves as a detailed beginner source of information for college ...
Software.Engineering_A.Practitioner's. Approach,8th.Edition,英文版,非扫描版 软件工程 实践者的研究方法 第8版 英文版,含目录 超清文字版 非扫描版 完整pdf 文字,图都超清晰,书本文字内容可选定复制
A Guide to Writing Sentences and Paragraphs 2009(8th Edition)
Elementary Statistics: A Step By Step Approach is for introductory statistics courses with a basic algebra prerequisite. The text follows a nontheoretical approach, explaining concepts intuitively and...
Indeed, Java is in a unique position to fulfill this promise. It is an extremely solidly engineered language that has gained acceptance by all major vendors, except for Microsoft. Its built-in ...
Sams Teach Yourself C++ in One Hour a Day ' In just one hour a day, you'll have all the skills you need to begin programming in C++. With this complete tutorial, you'll quickly master the basics and ...
Sams Teach Yourself C++ in One Hour a Day(8th) 英文无水印pdf 第8版 pdf使用FoxitReader和PDF-XChangeViewer测试可以打开