CF1519B.The Cake Is a Lie

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a n×mn \times m grid. You are standing at cell (1,1)(1, 1) and your goal is to finish at cell (n,m)(n, m).

You can move to the neighboring cells to the right or down. In other words, suppose you are standing at cell (x,y)(x, y). You can:

  • move right to the cell (x,y+1)(x, y + 1) — it costs xx burles;
  • move down to the cell (x+1,y)(x + 1, y) — it costs yy burles.

Can you reach cell (n,m)(n, m) spending exactly kk burles?

有一个 n×mn \times m 的网格。你起始于单元格 (1,1)(1, 1),目标是到达单元格 (n,m)(n, m)。

你只能向右或向下移动到相邻的单元格。换言之,假设你当前位于单元格 (x,y)(x, y),那么你可以:

  • 向右移动至单元格 (x,y+1)(x, y + 1) — 花费 xx 卢布;
  • 向下移动至单元格 (x+1,y)(x + 1, y) — 花费 yy 卢布。

你能否恰好花费 kk 卢布到达单元格 (n,m)(n, m)?

输入格式

The first line contains the single integer tt (1≤t≤1001 \le t \le 100) — the number of test cases.

The first and only line of each test case contains three integers nn, mm, and kk (1≤n,m≤1001 \le n, m \le 100; 0≤k≤1040 \le k \le 10^4) — the sizes of grid and the exact amount of money you need to spend.

第一行包含一个整数 tt(1≤t≤1001 \le t \le 100)—— 测试用例的数量。

每个测试用例仅有一行,包含三个整数 nn、mm 和 kk(1≤n,m≤1001 \le n, m \le 100;0≤k≤1040 \le k \le 10^4)—— 分别表示网格的尺寸以及你需要恰好花费的金额。

输出格式

For each test case, if you can reach cell (n,m)(n, m) spending exactly kk burles, print YES. Otherwise, print NO.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

对于每个测试用例,如果你恰好花费 kk 卢布就能到达单元格 (n,m)(n, m),则输出 YES;否则输出 NO。

你可以以任意大小写形式输出每个字母(例如,字符串 yEs、yes、Yes 和 YES 均被视为肯定回答)。

输入输出样例

  • 输入#1

    6
    1 1 0
    2 2 2
    2 2 3
    2 2 4
    1 4 3
    100 100 10000

    输出#1

    YES
    NO
    YES
    NO
    YES
    NO

说明/提示

In the first test case, you are already in the final cell, so you spend 00 burles.

In the second, third and fourth test cases, there are two paths from (1,1)(1, 1) to (2,2)(2, 2): (1,1)(1, 1) →\rightarrow (1,2)(1, 2) →\rightarrow (2,2)(2, 2) or (1,1)(1, 1) →\rightarrow (2,1)(2, 1) →\rightarrow (2,2)(2, 2). Both costs 1+2=31 + 2 = 3 burles, so it's the only amount of money you can spend.

In the fifth test case, there is the only way from (1,1)(1, 1) to (1,4)(1, 4) and it costs 1+1+1=31 + 1 + 1 = 3 burles.

在第一个测试用例中,你已位于目标格子,因此花费 00 卢布。

在第二、第三和第四个测试用例中,从 (1,1)(1, 1) 到 (2,2)(2, 2) 存在两条路径:(1,1)(1, 1) →\rightarrow (1,2)(1, 2) →\rightarrow (2,2)(2, 2) 或 (1,1)(1, 1) →\rightarrow (2,1)(2, 1) →\rightarrow (2,2)(2, 2)。两条路径的花费均为 1+2=31 + 2 = 3 卢布,因此这是你唯一可能花费的金额。

在第五个测试用例中,从 (1,1)(1, 1) 到 (1,4)(1, 4) 只有一条路径,其花费为 1+1+1=31 + 1 + 1 = 3 卢布。

输入解题思路,AI测评打分。不知道怎么写?

首页