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. [原创]java WEB学习笔记84:Hibernate学习之路-- -映射 一对一关系 ,基外键的方式实现

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  2. bzoj 4358 permu

    比较容易想到莫队算法+线段树,但是这样时间复杂度是O(nsqrtnlogn)无法通过,考虑如果不进行删除操作,只有添加操作的话那么并查集就可以实现了,于是可以设定sqrtn块,每个块范围为(i-1)* ...

  3. ORA-12154的原因

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

  4. [div+css]竖排菜单

             }          #box{              width:120px;              font-size: 12px;              font- ...

  5. 真实的C++单例模式举例

    把构造函数声明为protected的理由很简单,但把构造函数声明为private的原因却很少知道.   从语法上讲,任何函数如果被声明为private,这个函数就不能从外部调用,构造函数也是函数,相反 ...

  6. android——单点触控移动,多点触控放大缩小

    xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to ...

  7. CentOS修改主机名和网络信息

    1.修改主机名称 [root@centos ~]# vim /etc/sysconfig/network打开文件,修改以下内容并保存 NETWORKING=yes #使用网络 HOSTNAME=cen ...

  8. 161128、Redis 4.0发布及其新功能介绍

    Redis 4.0-rc1 发布了,这是 4.0 的首个 RC 版.Redis 是一个高性能的key-value数据库.Redis 的出现,很大程度补偿了memcached这类keyvalue存储的不 ...

  9. 161027、Java 中的 12 大要素及其他因素

    对于许多人来说,"原生云"和"应用程序的12要素"是同义词.本文的目的是说有很多的原生云只坚持了最初的12个因素.在大多数情况下,Java 能胜任这一任务.在本 ...

  10. laravel页面间的传值

    可以在前端页面元素上添加onclick事件  onclick='selectRaw(this)' js中写function selectRaw(obj){ var data=$(obj).attr(& ...