目录

    • Educational Codeforces Round 108 (Rated for Div. 2)-B. The Cake Is a Lie
      • Problem Description
      • Input
      • Output
      • Sample Input
      • Sample Onput
      • Note
  • 题目大意
  • 解题思路
  • AC代码

Educational Codeforces Round 108 (Rated for Div. 2)-B. The Cake Is a Lie

传送门
Time Limit: 2 seconds
Memory Limit: 256 megabytes

Problem Description

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

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

Input

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

The first and only line of each test case contains three integers n n n, m m m, and k k k ( 1 ≤ n , m ≤ 100 1 \le n, m \le 100 1≤n,m≤100; 0 ≤ k ≤ 1 0 4 0 \le k \le 10^4 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 ) (n, m) (n,m) spending exactly k k 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).

Sample Input

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

Sample Onput

YES
NO
YES
NO
YES
NO

Note

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

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


题目大意

在一个二维坐标平面,从点 ( 1 , 1 ) (1,1) (1,1)出发到点 ( n , m ) (n,m) (n,m),
其中在点 ( x , y ) (x,y) (x,y)只能花费 y ¥ y¥ y¥到 x + 1 x+1 x+1,或者花费 x ¥ x¥ x¥到 y + 1 y+1 y+1,
问能不能花费 k ¥ k¥ k¥到达。


解题思路

其实不难发现,先在 x x x方向走动与先在 y y y方向走动,最终到达点 ( n , m ) (n,m) (n,m)所花费的 ¥ ¥ ¥是一样的。所以只需要先全部往 y y y方向走,到点 ( n , 1 ) (n,1) (n,1)后往 x x x方向走,直到到达点 ( n , m ) (n,m) (n,m),看花费是否正好等于 k k k即可。


AC代码

#include <bits/stdc++.h>
using namespace std;
int main()
{int N;cin>>N;while(N--){int n,m,k;cin>>n>>m>>k;int s=0;for(int i=1;i<n;i++)s+=1;for(int j=1;j<m;j++)s+=n;puts(s==k?"YES":"NO");}return 0;
}

原创不易,转载请附上原文链接哦~
Tisfy:https://letmefly.blog.csdn.net/article/details/116330973

Educational Codeforces Round 108 (Rated for Div. 2)-B. The Cake Is a Lie-题解相关推荐

  1. Educational Codeforces Round 108(Rated for Div. 2) E - Off by One(一种一般图的边最大匹配,好题)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 CF1519E Weblink https://codeforces.com/contest/1519 ...

  2. Educational Codeforces Round 108 (Rated for Div. 2) D. Maximum Sum of Products 思维 + dp

    传送门 文章目录 题意: 思路: 题意: 给你两个长度为nnn的数组a,ba,ba,b,你可以至多反转一段连续区间,求∑i=1nai∗bi\sum _{i=1}^n a_i*b_i∑i=1n​ai​∗ ...

  3. Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...

  4. Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...

  5. Educational Codeforces Round 37 (Rated for Div. 2) 1

    Educational Codeforces Round 37 (Rated for Div. 2) A.Water The Garden 题意:Max想给花园浇水.花园可被视为长度为n的花园床,花园 ...

  6. Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)

    Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...

  7. Educational Codeforces Round 89 (Rated for Div. 2)(A, B, C, D)

    Educational Codeforces Round 89 (Rated for Div. 2) A. Shovels and Swords 思路 题意非常简单,就是得到最多的物品嘛,我们假定a, ...

  8. Educational Codeforces Round 114 (Rated for Div. 2) D. The Strongest Build 暴力 + bfs

    传送门 文章目录 题意: 思路: 题意: 你有nnn个装备槽,每个槽里面有cic_ici​个力量加成,对于每个槽只能选一个力量加成,现在给你mmm个力量组合[b1,b2,...,bn][b_1,b_2 ...

  9. Educational Codeforces Round 72 (Rated for Div. 2) D. Coloring Edges dfs树/拓扑找环

    传送门 文章目录 题意: 思路: 题意: 给你一张图,你需要给这个图的边染色,保证如果有环那么这个环内边的颜色不全相同,输出染色方案和用的颜色个数. n,m≤5e3n,m\le5e3n,m≤5e3 思 ...

最新文章

  1. dubbo 即是服务提供者又是消费者_Dubbo详细介绍与安装使用过程
  2. 给element-ui的steps加点击事件
  3. oracle 数据库字段名与实体类字段名称不匹配的处理方法
  4. Exception in thread “main“ java.lang.UnsupportedOperationException Arrays.asList中add报错
  5. 更改VMware硬盘大小
  6. 使用pscp在Linux、Windows间互传文件
  7. 二叉树的非递归遍历实现
  8. UI——day15.H5和小程序的设计
  9. iOS 获取屏幕方向,和强制屏幕旋转
  10. 图片alt属性添加方法
  11. PLC 数据内存读写 调试软件工具
  12. iOS开发:对于动态库共享缓存(dyld)的了解
  13. 给移动硬盘安装PE系统
  14. English--consonant_爆破音
  15. 移动用户体验设计:iOS APP体验设计
  16. 热门股权项目:富滇银行股份有限公司0.0232%股权转让
  17. Java面试:数据库,Java,框架,前端技术。应有尽有
  18. 又一家中国IC进军IPO:年出货上亿颗,在做Type-C 8K芯片
  19. html颜色代码 糖果色,75平米糖果色跃层家 绚丽色彩散发迷人魅力
  20. 软件工程专业的论文答辩_2015软件工程硕士论文答辩流程

热门文章

  1. HTML - Canvas 使用画布旋转文本
  2. Ag掺杂改性金属有机骨架多孔材料MIL-101|核壳结构的MOF@TiO2催化剂(NH2-UiO-66@TiO2)科研试剂
  3. win10 任务栏最右端的竖线
  4. 2021年安全员-B证考试APP及安全员-B证证考试
  5. PHP 文心千帆API接口对接
  6. 解决Win11开机内存占用过高的情况
  7. sslcontext java_java SSLContext
  8. java map遍历_Java 循环遍历 Map
  9. MjAyMDAzMDk=
  10. C++语言常见问题解答(1) (转)