Gym 101028G-The Tower of Evil
来源:互联网 发布:解放军纪律知乎 编辑:程序博客网 时间:2024/05/16 08:50
题目描述:
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 hash floors (numbered from 1 to h, bottom to top), each floor hasw rooms (numbered from 1 to w, left to right) composing a row. The monster stands in one of the ground floor (floor number1) rooms (the room number d where1 ≤ 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 integerT, the number of the test cases. Each of the following lines contains a test case and consists of a three space-separated integersh, w andd 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.
Sample Input
59 4 29 4 35 4 310 2 110 2 2
NoYesYesNoYes
代码实现:
#include<iostream>
using namespace std;
int main()
{
int t,h,a,w,d;
cin>>t;
while(t--)
{
cin>>h>>w>>d;
a=h;
if(a%(w*2-2)==0)
{
a=2;
}
else
{
a%=(w*2-2);
}
if((a==d)||((a+d)==(2*w)))
{
cout<<"Yes\n";
}
else
{
cout<<"No\n";
}
}
return 0;
}
1.题意:往下抛石子的时候是要往右下角的房间里面抛,一个房间一个房间走,一层一层走
2.余数等于0的时候,是正好a=2
- Gym 101028G-The Tower of Evil
- 个人赛&cf G题:The Tower of Evil 模拟&数学
- THE TOWER OF HANOI
- The Tower of Babylon
- THE TOWER OF HANOI
- The Tower of Babylon
- 汉诺塔(the Tower of Hanoi )
- 437 - The Tower of Babylon
- poj2241 - The Tower of Babylon
- 1.1 The Tower of Hanoi
- UVA437- - The Tower of Babylon
- UVa437 The Tower of Babylon
- Uva437 The Tower of Babylon
- UVA437 - The Tower of Babylon
- Uva The Tower of Babylon
- uva437 - The Tower of Babylon
- UVA437 The Tower of Babylon
- uva437 the tower of babylon
- maven如何手动导入ojdbc6.jar或ojdbc14
- Mondrian 4 测试的简单demo(Saiku简单测试Schema文件)
- python网络天气爬虫
- HDU 4408 Minimum Spanning Tree(最小生成树计数)
- 防止sql注入
- Gym 101028G-The Tower of Evil
- Canvas之绘制基本形状
- Spring中的jar包简介
- 多进程下的单实例和全局变量
- java实现愤怒的小鸟游戏之Java swing图形界面开发游戏项目愤怒的小鸟源码及实现方式详解
- JZOJ1422. 猴子摘桃
- 人月神话读书笔记(2)----人月神话
- Zynq VDMA 自测
- angular的分页代码示例