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. [译]C++如何切分字符串

    声明: 翻译仅以技术学习和交流为目的,如需转载请务必标明原帖链接. http://stackoverflow.com/questions/236129/how-to-split-a-string-in ...

  2. vs2008试用期到期解决办法

    vs2008试用期结束之后,     在“控制面板”中启动“添加删除程序”,      选中Vs2008,点击“更改.删除”,      在出现的维护模式对话框中, 选择下一步,输入下面的CD-Key ...

  3. 《Android开发艺术探索》读书笔记 (13) 第13章 综合技术、第14章 JNI和NDK编程、第15章 Android性能优化

    第13章 综合技术 13.1 使用CrashHandler来获取应用的Crash信息 (1)应用发生Crash在所难免,但是如何采集crash信息以供后续开发处理这类问题呢?利用Thread类的set ...

  4. yii redirect

    redirect 这个方法是在 CController 里定义的 先来看下官方介绍 redirect() 方法 public void redirect(mixed $url, boolean $te ...

  5. python增删改查

    ###增删改查 names = ["zhangding","wangxu","wudong","cheng"] #增na ...

  6. struts2学生信息管理系统篇章③

    package com.java1234.util; public class PageUtil { //传进来四个参数,tagetUtil是跳转链接的头部,totalNum是总个数,currentP ...

  7. Hibernate HQL查询:

    Hibernate HQL查询:Criteria查询对查询条件进行了面向对象封装,符合编程人员的思维方式,不过HQL(Hibernate Query Lanaguage)查询提供了更加丰富的和灵活的查 ...

  8. CI 模型的使用M与C之间的调用

    CI是PHP一个比较轻,并且好用的一个框架 分层也是分的比较清晰的一个 这里先展示MODEL 放在application/models 目录下面user_model.php <?php clas ...

  9. (转)DEDECMS 如何让栏目外部链接在新窗口中打开

    近遇到一个问题,就是dedecms的导航,是用外部链接的,但是原窗口打开不好看,新窗口打开好点.OK,放狗... 1. 查找模板中的head.htm将<li><a href='[fi ...

  10. 一个PHP开发者总结的九条建议

    本文只是个人从实际开发经验中总结的一些东西,并不是什么名言警句,写出来有两个目的:一是时刻提醒自己要按照这些知识点来写自己代码,二是为了分享,说不定对你有用呢?万一,是吧... 1.首要意识:安全 大 ...