2016 Al-Baath University Training Camp Contest-1 G
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!
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 h, w 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).
For each test case print a single line: 'Yes' if the monster will be killed and 'No' otherwise.
5
9 4 2
9 4 3
5 4 3
10 2 1
10 2 2
No
Yes
Yes
No
Yes

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的更多相关文章
- 2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...
- 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 ...
- 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 ...
- 2016 Al-Baath University Training Camp Contest-1 B
Description A group of junior programmers are attending an advanced programming camp, where they lea ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 20145207《Java程序设计》第6周学习总结
教材学习内容总结 一.输入/输出 InputStream与Outputstream • 串流设计的概念 从应用程序角度看,将数据从来源取出,可以使用输入串流,将数据写入目的地,可以使用输出串流:在Ja ...
- [原创]java WEB学习笔记82:Hibernate学习之路---映射 一对多关联关系,配置,CRUD方法测试及注意点
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- Android--HTTP协议
1 package com.http.get; 2 3 import java.io.FileOutputStream; 4 import java.io.IOException; 5 import ...
- kafka0.8.2以下版本删除topic
一些说明 kafka0.8.2及以上版本已经支持delete命令删除topic,可是之前的版本要是想删除topic还是要费一番手脚,绝对是个体力活... 该方法最好仅在线下开发环境中使用,毕竟要重启z ...
- SparkSQL JSON数据操作(1.3->1.4)
1.用户自定义schema data json串格式如下: { "partner_code": "demo", "app_name": &q ...
- php操作oracle的方法类集全
在网上开始找php中操作oracle的方法类~ 果然找到一个用php+oracle制作email表以及插入查询的教程,赶忙点开来看,从头到尾仔细的看了一遍,还没开始操作,便觉得收获很大了.地址在此:h ...
- PAT乙级 1025. 反转链表 (25)
1025. 反转链表 (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 给定一个常数K以及一个单链表L,请 ...
- PAT乙级 1007. 素数对猜想 (20)
1007. 素数对猜想 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 让我们定义 dn 为:dn = ...
- Left Join 与Right Join 与 Inner Join 与 Full Join的区别
首先看看Left Join 与Right Join 与 Inner Join 与 Full Join对表进行操作后得到的结果. 在数据库中新建两张表,并插入要测试的数据. 新建表: USE [Test ...
- linux设备驱动归纳总结(三):5.阻塞型IO实现【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-60025.html linux设备驱动归纳总结(三):5.阻塞型IO实现 xxxxxxxxxxxxxx ...