博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nasty Hacks <入门练手题>
阅读量:5108 次
发布时间:2019-06-13

本文共 1767 字,大约阅读时间需要 5 分钟。

Nasty Hacks

Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2047 Accepted Submission(s): 1280
 
Problem Description
You are the CEO of Nasty Hacks Inc., a company that creates small pieces of malicious software which teenagers may use
to fool their friends. The company has just finished their first product and it is time to sell it. You want to make as much money as possible and consider advertising in order to increase sales. You get an analyst to predict the expected revenue, both with and without advertising. You now want to make a decision as to whether you should advertise or not, given the expected revenues.
 
Input
The input consists of n cases, and the first line consists of one positive integer giving n. The next n lines each contain 3 integers, r, e and c. The first, r, is the expected revenue if you do not advertise, the second, e, is the expected revenue if you do advertise, and the third, c, is the cost of advertising. You can assume that the input will follow these restrictions: -10
6
 ≤ r, e ≤ 10
6
 and 0 ≤ c ≤ 10
6.
 
Output
Output one line for each test case: “advertise”, “do not advertise” or “does not matter”, presenting whether it is most profitable to advertise or not, or whether it does not make any difference.
 
Sample Input
30 100 70100 130 30-100 -70 40
 
Sample Output
advertisedoes not matterdo not advertise
 
    
                

     代码:

                 #include<stdio.h>

                 int main(void)
                {
                    int n;
                    long a[3],t;
                    scanf("%d",&n);
                    while(n--)
                   {
                         scanf("%ld%ld%ld",&a[0],&a[1],&a[2]);
                         t=a[1]-a[0];
                         if(t>a[2]) printf("advertise\n");
                         else if(t==a[2]) printf("does not matter\n");
                         else printf("do not advertise\n");
                   }
 
                 }

               注:使用while循环时应注意“循环结束”问题,不然会出现提交错误,如Output Limit Exceeded(超时)。

转载于:https://www.cnblogs.com/tmy257/p/3191696.html

你可能感兴趣的文章
Linux内核态、用户态简介与IntelCPU特权级别--Ring0-3
查看>>
第23月第24天 git命令 .git-credentials git rm --cached git stash clear
查看>>
java SE :标准输入/输出
查看>>
一些方便系统诊断的bash函数
查看>>
jquery中ajax返回值无法传递到上层函数
查看>>
css3之transform-origin
查看>>
[转]JavaScript快速检测浏览器对CSS3特性的支持
查看>>
Master选举原理
查看>>
[ JAVA编程 ] double类型计算精度丢失问题及解决方法
查看>>
小别离
查看>>
微信小程序-发起 HTTPS 请求
查看>>
WPF动画设置1(转)
查看>>
基于node/mongo的App Docker化测试环境搭建
查看>>
秒杀9种排序算法(JavaScript版)
查看>>
Activiti入门 -- 环境搭建和核心API简介
查看>>
struts.convention.classes.reload配置为true,tomcat启动报错
查看>>
MySQL的并行复制多线程复制MTS(Multi-Threaded Slaves)
查看>>
好玩的-记最近玩的几个经典ipad ios游戏
查看>>
PyQt5--EventSender
查看>>
Sql Server 中由数字转换为指定长度的字符串
查看>>