HDU 6048 Puzzle(找规律)——2017 Multi-University Training Contest
来源:互联网 发布:ec6108v9怎么安装软件 编辑:程序博客网 时间:2024/05/28 15:17
传送门
Puzzle
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 405 Accepted Submission(s): 216
Problem Description
A Jigsaw puzzle contains N*M-1 pieces of jigsaws in a N rows*M columns rectangular board.Each jigsaw has a distinct number from 1 to N*M-1.Li is a naughty boy,he wants to arrange the board in his unique way.At the beginning,he picks all N*M-1 jigsaws out and put them on the table and then he will put them back to the board respecting the following steps:
1.Sorting all the remaining jigsaws on the table in ascending order.
2.Picking out the 1st ,the P+1 th ,the 2*P+1 th,……the n*P+1 th jigsaws and put them back to the blank area in the board one by one from the top row to the bottom row,from the left column to the right column.
3.if there are jigsaws remained on the table,back to step 1.
After he arranging the board,it’s obvious that there’s only one blank area located at the bottom-right corner.
Your task is to make the numbers on jigsaws sorted with every row and every column in ascending order(From left to right,top to bottom),and the blank area should be located at the bottom-right corner in the end.Each step you can move the blank area’s neighboring jigsaws(which share a common side with the blank area) towards the blank area.It’s really a difficult question,so you need to write a program to judge whether it is possible to complete the task.
1.Sorting all the remaining jigsaws on the table in ascending order.
2.Picking out the 1st ,the P+1 th ,the 2*P+1 th,……the n*P+1 th jigsaws and put them back to the blank area in the board one by one from the top row to the bottom row,from the left column to the right column.
3.if there are jigsaws remained on the table,back to step 1.
After he arranging the board,it’s obvious that there’s only one blank area located at the bottom-right corner.
Your task is to make the numbers on jigsaws sorted with every row and every column in ascending order(From left to right,top to bottom),and the blank area should be located at the bottom-right corner in the end.Each step you can move the blank area’s neighboring jigsaws(which share a common side with the blank area) towards the blank area.It’s really a difficult question,so you need to write a program to judge whether it is possible to complete the task.
Input
The first line contains an integer T(T<=100),which represents the number of test cases.
Following T lines,each line contains three integers N,M,P(2<=N,M<=1000;1<=P<=N*M-2).
Following T lines,each line contains three integers N,M,P(2<=N,M<=1000;1<=P<=N*M-2).
Output
For each test case,print “YES” in a separate line if it is possible to complete the task ,otherwise please print “NO”.
Sample Input
3
3 2 3
3 2 4
999 999 1
Sample Output
YES
NO
YES
题目大意:
给定一个
解题思路:
其实题解已经说的很详细了,其实就是个找规律,然而发现找到这样的规律还是挺难的,只有多做题,多见识才能找到其中的规律。
官方题解:
Code:
#include <bits/stdc++.h>using namespace std;typedef long long LL;int main(){ int T; scanf("%d", &T); while(T--){ int n, m, p; scanf("%d%d%d", &n, &m, &p); LL all = n * m - 1, ans = 0; while(all > p){ LL tv = (all - 1) / p + 1; all -= tv; tv = (tv - 1) * tv / 2; ans += tv * (p - 1); } if(ans & 1) puts("NO"); else puts("YES"); }}
阅读全文
0 0
- HDU 6048 Puzzle(找规律)——2017 Multi-University Training Contest
- HDU 6038 Function(找规律)——2017 Multi-University Training Contest
- HDU 5826 physics(积分 找规律)——2016 Multi-University Training Contest 8
- HDU 5399 Too Simple(数学 + 找规律)——2015 Multi-University Training Contest 9
- hdu 6038 找规律 置换 2017 Multi-University Training Contest
- HDU 5351 MZL's Border(大数 + 找规律)——2015 Multi-University Training Contest 5
- 2017 Multi-University Training Contest 10 1002 Array Challenge HDU 6172(找规律 矩阵快速幂)
- HDU 5754 Life Winner Bo(找规律 + 威佐夫博弈)--2016 Multi-University Training Contest 3
- HDU 5319 Painter(模拟 + 规律)——2015 Multi-University Training Contest 3
- HDU 5795 A Simple Nim(SG打表找规律)——2016 Multi-University Training Contest 6
- HDU 5810 Balls and Boxes(打表找规律)——2016 Multi-University Training Contest 7 1002
- HDU 6055 Regular polygon(计算几何+思维)——2017 Multi-University Training Contest
- HDU 6053 TrickGCD(分块+容斥)——2017 Multi-University Training Contest
- HDU 6127 Hard challenge(思维+计算几何)——2017 Multi-University Training Contest
- HDU 6128 Inverse of sum(数论)——2017 Multi-University Training Contest
- HDU 3068 2017 Multi-University Training Contest
- HDU 6034 & 2017 Multi-University Training Contest
- hdu 6034 2017 Multi-University Training Contest
- JAVASCRIPT的第六天
- 深入Java单例模式
- java 数组
- Generator 函数基础(一) (The Basics of ES6 Generators)
- TCP 连接管理与释放(三次握手,四次挥手)
- HDU 6048 Puzzle(找规律)——2017 Multi-University Training Contest
- 关于小程序在后台换取openid的方法
- Integer包装类比较时“==”和equals()的区别及原因
- JVM 新生代为何需要两个 Survivor 空间?
- c++存储持续性、作用域和链接性
- 字符串右移
- Nginx secure_link防盗链模块
- C++ 获取linux和windows系统的用户名
- Hyperledger Fabric 相关概念