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

3

2 3 4

2 3 6

2 3 9

Sample Output

Sempr!

Both!

Xiangsanzi!

就是输入a b t。

Sempr在每过a个时间提交一次代码,

Xiangsanzi在每过b个时间提交一次代码,

问在t时间内,谁提交的代码量多。

注意,他们编程速度什么的都是一样的!每时每刻都在编程!是提交的代码量谁多一些!

也就是说,看他们最后一次提交代码,谁距离t时间最近,谁就提交的多。

实际上就是a%t,b%t的余数来比较大小,谁的余数小,就输出谁。

import java.util.Scanner;

public class Main{
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int t =sc.nextInt();
while(t-->0){
int a = sc.nextInt();
int b =sc.nextInt();
int tm = sc.nextInt();
if(tm%a==tm%b){
System.out.println("Both!");
continue;
}
if(tm%a<tm%b){
System.out.println("Sempr!");
continue;
}
System.out.println("Xiangsanzi!");
}
}
}

HDOJ(HDU) 1898 Sempr == The Best Problem Solver?(水题、、、)的更多相关文章

  1. hdoj 1898 Sempr == The Best Problem Solver?

    Sempr == The Best Problem Solver? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/3276 ...

  2. HDOJ/HDU 1256 画8(绞下思维~水题)

    Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...

  3. HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)

    Problem Description background: A new semester comes , and the HDU also meets its 50th birthday. No ...

  4. HDU 4716 A Computer Graphics Problem (水题)

    A Computer Graphics Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  5. fzuoj Problem 2182 水题

    http://acm.fzu.edu.cn/problem.php?pid=2182 Problem 2182 水题 Accept: 188    Submit: 277Time Limit: 100 ...

  6. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出

    这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999  Problem Description: As we know,the sha ...

  8. 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem A: The 3n + 1 problem(水题)

    Problem A: The 3n + 1 problem Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 14  Solved: 6[Submit][St ...

  9. hdu 1164:Eddy's research I(水题,数学题,筛法)

    Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

随机推荐

  1. 案例:利用累加器计算前N个学生的总成绩和平均成绩

    /* *录入N个学生的成绩,并求出这些学生的总成绩和平均成绩! * */ import java.util.Scanner; public class SumTest{ public static v ...

  2. JavasScript基数排序

    基数排序   91, 46, 85, 15, 92, 35, 31, 22经过基数排序第一次扫描之后, 数字被分配到如下盒子中:Bin 0:Bin 1: 91, 31Bin 2: 92, 22Bin ...

  3. (转)dedecms [field:array runphp='yes']标签使用技巧

    field支持用array获取任意字段的值:(支持标记:文章内容模板的 {dede:field name=’array’ /}.arclist.arclistsg.loop.sql 标签) 我们平时常 ...

  4. SQLServer2008收缩数据库日志

    -- Set to SIMPLE mode ALTER DATABASE [DATABASE_NAME] SET RECOVERY SIMPLE; -- Shrink the db ); -- Set ...

  5. REST和SOAP Web Service的比较

    1.http://stevenjohn.iteye.com/blog/1442776 2.http://blog.csdn.net/cnyyx/article/details/7483766

  6. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第三章:搜索、高级过滤和视图模型

    在这一章中,我们首先添加一个搜索产品的模块以增强站点的功能,然后使用视图模型而不是ViewBag向视图传递复杂数据. 注意:如果你想按照本章的代码编写示例,你必须完成第二章或者直接从www.apres ...

  7. 如果使用的是orm,是否还需要关系索引

    简而言之:是的,仍然需要理解索引,即使是使用对象关系映射(ORM)工具. ORM工具能够产生符合逻辑的,合法的查询(多数的时候),除非只是生成非常基本的查询(例如仅是根据主键查询的),否则它很难生成适 ...

  8. PHP添加、更新solr索引

    <?php $options = array ( 'hostname' => 'localhost', 'port' => '8080', 'path'=>'solr/help ...

  9. 在fragment中获取他附着的activity中的变量

    final String data=(关联的activity类)getActivity().getData(); getData();自定义的方法

  10. 封装兼容性添加、删除事件的函数 addEventListener与removeEventListener

    var Event = { addHandler: function (oElement, sEvent, fnHandler) { oElement.addEventListener ? oElem ...