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

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
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int t,n,m,k;
int mp[][];
int main()
{
while(~scanf("%d",&t))
{
for(;t>;t--)
{
scanf("%d%d%d",&n,&m,&k);
k=(n-)*(m-)-k;
for(int i=;i<=n;i++)
{
printf("");
for(int j=;j<m;j++)
if (k>) printf(" %d",k--);
else printf("");
printf(" 0\n");
}
}
}
return ;
}

zoj 3212 K-Nice(构造)的更多相关文章

  1. ZOJ 3212 K-Nice(满足某个要求的矩阵构造)

    H - K-Nice Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Sta ...

  2. ZOJ 3632 K - Watermelon Full of Water 优先队列优化DP

    K - Watermelon Full of Water Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%lld &am ...

  3. ZOJ 3599 K倍动态减法游戏

    下面的文字辅助理解来自http://blog.csdn.net/tbl_123/article/details/24884861 博弈论中的 K倍动态减法游戏,难度较大,参看了好多资料才懵懂! 此题可 ...

  4. n=C(2,n)+k(构造)( Print a 1337-string)Educational Codeforces Round 70 (Rated for Div. 2)

    题目链接:https://codeforc.es/contest/1202/problem/D 题意: 给你一个数 n ( <=1e9 ),让你构造137713713.....(只含有1,3,7 ...

  5. zoj 3823 Excavator Contest 构造

    Excavator Contest Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/show ...

  6. ZOJ 3212 K-Nice

    K-Nice Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge This is a super simple pr ...

  7. ACM-ICPC 2018 青岛赛区现场赛 D. Magic Multiplication && ZOJ 4061 (思维+构造)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4061 题意:定义一个长度为 n 的序列 a1,a2,..,an ...

  8. 求n^k的前缀和

    我都已经高二了,却还不知\(1^2+2^2+3^2+4^2+...+n^2\)的通式,真是惭愧. 现在说说如何求\(n^k\)的前缀和. 如果k比较小,我们可以直接差分序列手算.否则,我们可以用神奇的 ...

  9. hdu1757 构造矩阵

    Lele now is thinking about a simple function f(x). If x < 10 f(x) = x.If x >= 10 f(x) = a0 * f ...

随机推荐

  1. oracle创建表空间、用户和表以及sys和system的区别

    一.oracle的3个内置账号(口令管理)scott(示范账户) tiger 内置账号system 系统管理员 操作用户sys 超级管理员 操作数据 conn system/sasa;show use ...

  2. GSM/GPRS/3G/4G

    1.状态机机制的gprs拨号 像GPRS/3G模块之类的应用,需要连接,登陆,初始化等步骤完成后才能传输数据,而这些步骤又比较耗时. 所以用 状态机 + 超时 的机制来实现比较合理. 如下代码片段来描 ...

  3. 在用 JavaScript 工作时,我们经常和条件语句打交道,这里有5条让你写出更好/干净的条件语句的建议。

    1.多重判断时使用 Array.includes 2.更少的嵌套,尽早 return 3.使用默认参数和解构 4.倾向于遍历对象而不是 Switch 语句 5.对 所有/部分 判断使用 Array.e ...

  4. bootstrap select 学习使用笔记-------选中赋值及change监听丢失

    在 bootstrap 和 knockout 共同存在下使用 select 下拉选择插件,发现绑定选项.赋值之后插件不可用了,绑定的监听事件也丢失了.迫不得已在绑定选项值之后再次调用刷新,以及赋值后重 ...

  5. LeetCode:组合总数II【40】

    LeetCode:组合总数II[40] 题目描述 给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合. candi ...

  6. SqlHelper简单实现(通过Expression和反射)1.引言

    之前老大说要改变代码中充斥着各种Select的Sql语句字符串的情况,让我尝试着做一个简单的SqlHelper,要具有以下功能: 1.不要在业务代码中暴露DataTable或者DataSet类型: 2 ...

  7. 如何生成.a文件,小心有坑!!

    .a文件是一种对实现文件细节进行隐藏的打包文件. 由于是打包文件,所以需要创建工程,将功能代码添加到工程.下面是创建.a文件的具体步骤: Step One:打开Xcode(此处使用的Xcode 8.2 ...

  8. Linux设备驱动程序加载/卸载方法 insmod和modprobe命令

    linux加载/卸载驱动有两种方法. 1.modprobe 注:在使用这个命令加载模块前先使用depmod -a命令生成modules.dep文件,该文件位于/lib/modules/$(uname ...

  9. Spark机器学习4·分类模型(spark-shell)

    线性模型 逻辑回归--逻辑损失(logistic loss) 线性支持向量机(Support Vector Machine, SVM)--合页损失(hinge loss) 朴素贝叶斯(Naive Ba ...

  10. tesseract编译各种 “锟斤拷” 等中文乱码 编译失败问题

    编译tesseract - ocr时 各种不通过 也很疑惑,完全按照官方指导来的啊 首先以为是vs的编码问题,随切换选项-切换Unicode或多编码字符集,但仍无效. 定位到乱码的文件,用notepa ...