CodeForces - 1519B The Cake Is a Lie

Posted 海岛Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces - 1519B The Cake Is a Lie相关的知识,希望对你有一定的参考价值。

B. The Cake Is a Lie
time limit per test2 seconds
memory limit per test256 megabytes

There is a n×m grid. You are standing at cell (1,1) and your goal is to finish at cell (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). You can:

move right to the cell (x,y+1) — it costs x burles;
move down to the cell (x+1,y) — it costs y burles.
Can you reach cell (n,m) spending exactly k burles?

Input
The first line contains the single integer t (1≤t≤100) — the number of test cases.

The first and only line of each test case contains three integers n, m, and k (1≤n,m≤100; 0≤k≤104) — the sizes of grid and the exact amount of money you need to spend.

Output
For each test case, if you can reach cell (n,m) spending exactly k 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).

Example
input
6
1 1 0
2 2 2
2 2 3
2 2 4
1 4 3
100 100 10000
output
YES
NO
YES
NO
YES
NO

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

In the second, third and fourth test cases, there are two paths from (1,1) to (2,2): (1,1) → (1,2) → (2,2) or (1,1) → (2,1) → (2,2). Both costs 1+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) to (1,4) and it costs 1+1+1=3 burles.

问题链接CodeForces - 1519B The Cake Is a Lie
问题简述:(略)
问题分析:(略)
AC的C++语言程序如下:

/* CodeForces - 1519B The Cake Is a Lie */

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    while (t--) {
        int n, m, k;
        scanf("%d%d%d", &n, &m, &k);
        k -= n - 1;
        k -= n * (m - 1);
        puts(k ? "NO" : "YES");
    }

    return 0;
}

以上是关于CodeForces - 1519B The Cake Is a Lie的主要内容,如果未能解决你的问题,请参考以下文章

CodeForces 518A - Chewbaсca and Number(思路)

checkpoint 防火墙系统报错1--the internal CA certificate failed(内部CA损坏)

extract the CA cert for a particular server

CodeForces 622B The Time

Educational Codeforces Round 7 F - The Sum of the k-th Powers 拉格朗日插值

CodeForces 625B War of the Corporations