标签:hdu 数学
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1898
Problem Description
As is known to all, Sempr(Liangjing Wang) had solved more than 1400 problems on POJ, but nobody know the days and nights he had spent on solving problems.
Xiangsanzi(Chen Zhou) was a perfect problem solver too. Now this is a story about them happened two years ago.
On March 2006, Sempr & Xiangsanzi were new comers of hustacm team and both of them want to be "The Best New Comers of March", so they spent days and nights solving problems on POJ.
Now the problem is below: Both of them are perfect problem solvers and they had the same speed, that is to say Sempr can solve the same amount of problems as Xiangsanzi, but Sempr enjoyed submitting all the problems at the end of every A hours but Xiangsanzi
enjoyed submitting them at the end of every B hours. In these days, static(Xiaojun Wu) was the assistant coach of hustacm, and he would check the number of problems they solved at time T. Give you three integers A,B,and T, you should tell me who is "The Best
New Comers of March". If they solved the same amount of problems, output "Both!". If Sempr or Xiangsanzi submitted at time T, static would wait them.
Input
In the first line there is an integer N, which means the number of cases in the data file, followed by N lines.
For each line, there are 3 integers: A, B, T.
Be sure that A,B and N are no more than 10000 and T is no more than 100000000.
Output
For each case of the input, you should output the answer for one line. If Sempr won, output "Sempr!". If Xiangsanzi won, output "Xiangsanzi!". And if both of them won, output "Both!".
Sample Input
Sample Output
Author
Sempr|CrazyBird|hust07p43
Source
思路:
寻找谁利用的时间更多一些!
代码如下:
#include <cstdio>
int main()
{
int t;
int A, B, T;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&A,&B,&T);
int a1 = T/A;
int a2 = T/B;
int b1 = T - a1*A;
int b2 = T - a2*B;
if(b1 > b2)
{
printf("Xiangsanzi!\n");
}
else if(b2 > b1)
{
printf("Sempr!\n");
}
else
printf("Both!\n");
}
return 0;
}
HDU 1898 Sempr == The Best Problem Solver?(数学题)
标签:hdu 数学
原文地址:http://blog.csdn.net/u012860063/article/details/39321533