2 shunfurh shunfurh 于 2017.01.07 14:08 提问

K-Nice

Description
This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you don't, just pretend that you can't see this one.
We say an element is inside a matrix if it has four neighboring elements in the matrix (Those at the corner have two and on the edge have three). An element inside a matrix is called "nice" when its value equals the sum of its four neighbors. A matrix is called "k-nice" if and only if k of the elements inside the matrix are "nice".
Now given the size of the matrix and the value of k, you are to output any one of the "k-nice" matrix of the given size. It is guaranteed that there is always a solution to every test case.
Input
The first line of the input contains an integer T (1 <= T <= 8500) followed by T test cases. Each case contains three integers n, m, k (2 <=n, m <= 15, 0 <= k <= (n - 2) * (m - 2)) indicating the matrix size n * m and it the "nice"-degree k.
Output
For each test case, output a matrix with n lines each containing m elements separated by a space (no extra space at the end of the line). The absolute value of the elements in the matrix should not be greater than 10000.
Sample Input
2
4 5 3
5 5 3
Sample Output
2 1 3 1 1
4 8 2 6 1
1 1 9 2 9
2 2 4 4 3
0 1 2 3 0
0 4 5 6 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

1个回答

caozhy
caozhy   Ds   Rxr 2017.01.13 23:51
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
K-Nice
This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you dont, just pretend that you cant see this one. We say an element is
K - K-Nice
This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you don't, just pretend that you can't see this one. We say an element is
zoj 3212 K-Nice(数学题)
zoj 3212 K-Nice(数学题)
ZOJ 3212 K-Nice(思维)
K-Nice Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on.
zoj 3212 K-Nice
zoj  3212   K-Nice                    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3212 构造 题目大意:矩阵中四周都有数并四周数之和等于当中数的,叫做nice,K-Nice代表此矩阵中有k个nice项。 题目分析:输入矩阵规模和k值,输出一个符合条件的矩阵
ZOJ 3212 K-Nice(构造)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3212 给出的范围是(n-2)*(m-2)   第二组样例也给出了提示,构造初始零矩阵,XJB构造保证有K个0是nice #include #include #include #include #include #include #include #include
省赛热身赛之 K-Nice
原题: Description     This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you don't, just pretend that you can't see this o
ZOJ 3212 K-Nice
Description This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you don't, just pretend that you can't see this one. We say
ZOJ 3212 K-Nice【】
K-Nice Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on
zoj 3212 K-Nice 解题报告
K - K-Nice Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3211 Description This is a super simple problem. The description is s