博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj 3212 K-Nice(构造)
阅读量:4944 次
发布时间:2019-06-11

本文共 1908 字,大约阅读时间需要 6 分钟。

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. 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 nmk (2 <= nm <= 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

24 5 35 5 3

Sample Output

2 1 3 1 14 8 2 6 11 1 9 2 92 2 4 4 30 1 2 3 00 4 5 6 00 0 0 0 00 0 0 0 00 0 0 0 0
#include 
#include
#include
using namespace std;int t,n,m,k;int mp[20][20];int main(){ while(~scanf("%d",&t)) { for(;t>0;t--) { scanf("%d%d%d",&n,&m,&k); k=(n-2)*(m-2)-k; for(int i=1;i<=n;i++) { printf("0"); for(int j=2;j
0) printf(" %d",k--); else printf(" 0"); printf(" 0\n"); } } } return 0;}

 

转载于:https://www.cnblogs.com/stepping/p/6401193.html

你可能感兴趣的文章
CSS实例:图片导航块
查看>>
poj1860 Currency Exchange(spfa判断正环)
查看>>
SQL CHECK 约束&Case when 的使用方法
查看>>
[整理]HTTPS和SSL证书
查看>>
[转载] Android 异步加载图片,使用LruCache和SD卡或手机缓存,效果非常的流畅
查看>>
水晶苍蝇拍:聊聊估值那些事儿——“指标”背后的故事 (2011-11-01 14:58:32)
查看>>
3.每周总结
查看>>
应用提交 App Store 上架被拒绝
查看>>
Android实现异步处理 -- HTTP请求
查看>>
数据清空js清空div里的数据问题
查看>>
Fortran中的指针使用
查看>>
移动终端app测试点总结
查看>>
14-6-27&28自学内容小结
查看>>
JSP
查看>>
---
查看>>
(第一组_GNS3)自反ACl
查看>>
hdu--1258--Sum It Up(Map水过)
查看>>
Spring @DeclareParents 的扩展应用实例
查看>>
VS2012更新Update1后帮助查看器无法打开
查看>>
Android 文件的读取和写入
查看>>