题目链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=2304
Julyed
Time Limit: 1000 MS Memory Limit: 131072 K
Total Submit: 55(23 users) Total Accepted: 23(23 users) Rating: Special Judge: No
Description
Julyed is a smart pretty girl and tomriddly is her boyfriend. Now tomriddly is on the bus to the airport to see Julyed. He still needs X minutes to get the airport. But Julyed will arrive in Y minutes. What’s worse is that the terrible traffic! The bus will have to stop here for Z minutes! Julyed will happily wait for tomriddly at most 10 minutes, but will be mad after waiting at least 30 minutes. What will happened when they meet?
Input
Multiple test cases. The first line contains a positive integer T (T <= 100), indicates the number of test cases.
Each test case contains three non-negative integers X, Y, Z (X, Y, Z <= 60) descripted as above in one line.
Output
One line per case.
If Julyed will be happy, output “memeda”(without quotes).
If Julyed will be mad, output “QAQ”(without quotes).
Otherwise output how long will Julyed wait.
Sample Input
4
10 10 0
10 10 10
10 5 10
60 10 60
Sample Output
memeda
memeda
15
QAQ
Source
“尚学堂杯”哈尔滨理工大学第六届程序设计竞赛
【思路分析】直接判断x+z-y的值在哪个区间就好了,然后直接输出。
【AC代码】
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
if(x+z-y<=10)
{
printf("memeda\n");
}
else if(x+z-y>=30)
{
printf("QAQ\n");
}
else
{
printf("%d\n",x+z-y);
}
}
return 0;
}