Description

The forces of evil are about to disappear since our hero is now on top on the tower of evil, and all what is left is the most evil, most dangerous monster! The tower has h floors (numbered from 1 to h, bottom to top), each floor has w rooms (numbered from 1 to w, left to right) composing a row. The monster stands in one of the ground floor (floor number 1) rooms (the room number d where 1 ≤ d ≤ w). Our hero stands in the top-left room of the tower. The only way for our hero to kill the evil monster is to throw down one of his power stones diagonally to the right. The stone will keep moving diagonally through the tower's rooms until it hits the right border of the tower, then it will change its direction to move down diagonally to the left until it hits the left border of the tower, then it will change its direction again and so on. This stone stops when it reaches the ground floor, if it stopped in the room of the monster, the monster is dead, otherwise the monster is still alive and the forces of evil will rise again! Help our hero to determine whether the stone will kill the monster or not!

Input

The input consists of several test cases. The first line of the input contains a single integer T, the number of the test cases. Each of the following lines contains a test case and consists of a three space-separated integers hw and d denoting the height of the tower, the width of the tower and the number of room containing the monster. (1 ≤ d ≤ 109), (2 ≤ h, w ≤ 109).

Output

For each test case print a single line: 'Yes' if the monster will be killed and 'No' otherwise.

Example
input
5
9 4 2
9 4 3
5 4 3
10 2 1
10 2 2
output
No
Yes
Yes
No
Yes
Note
                                                                                         

In the first test case, the path of the power stone is colored in red. However the dragon is in the room denoted with D, so the monster is still alive and the answer is 'No'.

题意:见图

解法:找规律,这里以2*w-2作为一个循环,循环里面以最高点为对称

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,w,h,d;
cin>>t;
while(t--)
{
cin>>h>>w>>d;
int num=2*w-2;
int mod=h%num;
//cout<<h%num<<endl;
if(mod>w)
{
mod=2*w-mod;
}
else if(mod==0)
{
mod=2;
}
if(mod==d)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
//cout<<mod<<endl;
}
return 0;
}

  

2016 Al-Baath University Training Camp Contest-1 G的更多相关文章

  1. 2016 Al-Baath University Training Camp Contest-1

    2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...

  2. 2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)

    2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest) Problem A. M ...

  3. 2016 Al-Baath University Training Camp Contest-1 E

    Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...

  4. 2016 Al-Baath University Training Camp Contest-1 B

    Description A group of junior programmers are attending an advanced programming camp, where they lea ...

  5. 2016 Al-Baath University Training Camp Contest-1 A

    Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...

  6. 2016 Al-Baath University Training Camp Contest-1 J

    Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...

  7. 2016 Al-Baath University Training Camp Contest-1 I

    Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...

  8. 2016 Al-Baath University Training Camp Contest-1 H

     Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...

  9. 2016 Al-Baath University Training Camp Contest-1 F

    Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...

随机推荐

  1. [转] MongoDB shell 操作 (查询)

    最近有用到mongoDB,每次都去查看官方文档很是费劲,自己准备写点东西.但在博客园上看到另外的一篇博文不错,就转载过来,加上点儿自己的修饰 左边是mongodb查询语句,右边是sql语句.对照着用, ...

  2. Missing artifact com.sun:tools:jar 1.5.0 终极解决方法

    在使用m2eclipse插件时,在pom.xml中添加struts2-core.jar包后,需要依赖java运行时的tools.jar进行依赖.但是,此时eclipse无法读取tools包,出现如下错 ...

  3. html随笔

    <!DOCTYPE HTML> <html> <head> <meta charset = "utf-8"> <script ...

  4. JQuery书写Ajax的几种方式?

    1 $.ajax({ type: "Post", //请求方式 ("POST" 或 "GET"), 默认为 "GET" ...

  5. ORA-12154的原因

    一个很难想到的引起ORA-12154的原因         使用OracleClient.OracleConnection时(我连的是Oracle 9i,其他版本未知),如果你的执行目录太长或者有括号 ...

  6. sql 去除列中内容的单引号

    update  [dbo].[历史数据补全$]  set  bankCardNo=replace(bankCardNo,'''','') 总共4个单引号,外边2个是字符串固有的2个,里边两个就表示是一 ...

  7. Python 入門語法和類型(转载学习)

    http://www.cnblogs.com/mcdou/archive/2011/08/02/2125016.html Python的设计目标之一是让源代码具备高度的可读性.它设计时尽量使用其它语言 ...

  8. 让git忽略文件模式的改变

    使用git的过程中发现,就算文件的内容没改变,只有文件的权限改变的话,git也会检测到文件被修改了. 解决方法是配置一下: git config --global core.filemode fals ...

  9. Android的适配器

    //====================ArrayAdapter=================================== public class List1 extends  Ac ...

  10. Unexpected error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xd2 in position 69: ordinal not in range(128)-解决办法