#P1258. Destination
Destination
题目描述
There is a grid. You are standing at cell and your goal is to finish at cell .
You can move to the neighboring cells to the right or down. In other words, suppose you are standing at cell . You can:
- move right to the cell — it costs yuan;
- move down to the cell — it costs yuan.
Can you reach cell spending exactly yuan?
输入格式
The first line contains the single integer — the number of test cases.
The first and only line of each test case contains three integers , , and — the sizes of grid and the exact amount of money you need to spend.
输出格式
For each test case, if you can reach cell spending exactly yuan, print YES. Otherwise, print NO.
样例
6
1 1 0
2 2 2
2 2 3
2 2 4
1 4 3
100 100 100
YES
NO
YES
NO
YES
NO
提示
In the first test case, you are already in the final cell, so you spend yuan.
In the second, third and fourth test cases, there are two paths from to : or . Both costs yuan, so it’s the only amount of money you can spend.
In the fifth test case, there is the only way from to and it costs yuan.