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. 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
#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(构造)的更多相关文章
- ZOJ 3212 K-Nice(满足某个要求的矩阵构造)
H - K-Nice Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Sta ...
- ZOJ 3632 K - Watermelon Full of Water 优先队列优化DP
K - Watermelon Full of Water Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%lld &am ...
- ZOJ 3599 K倍动态减法游戏
下面的文字辅助理解来自http://blog.csdn.net/tbl_123/article/details/24884861 博弈论中的 K倍动态减法游戏,难度较大,参看了好多资料才懵懂! 此题可 ...
- 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 ...
- zoj 3823 Excavator Contest 构造
Excavator Contest Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/show ...
- ZOJ 3212 K-Nice
K-Nice Time Limit: 1 Second Memory Limit: 32768 KB Special Judge This is a super simple pr ...
- ACM-ICPC 2018 青岛赛区现场赛 D. Magic Multiplication && ZOJ 4061 (思维+构造)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4061 题意:定义一个长度为 n 的序列 a1,a2,..,an ...
- 求n^k的前缀和
我都已经高二了,却还不知\(1^2+2^2+3^2+4^2+...+n^2\)的通式,真是惭愧. 现在说说如何求\(n^k\)的前缀和. 如果k比较小,我们可以直接差分序列手算.否则,我们可以用神奇的 ...
- hdu1757 构造矩阵
Lele now is thinking about a simple function f(x). If x < 10 f(x) = x.If x >= 10 f(x) = a0 * f ...
随机推荐
- java 使用LinkedList模拟一个堆栈或者队列数据结构
近期在复习下java基础,看了下java基础,在看到集合时突然发现想起来曾经面试有一道笔试题:模拟一个堆栈或者队列数据结构,当时还没做出来,今天就写一下,首先得明确堆栈和队列的数据结构 堆栈:先进后出 ...
- oracle入门(3)——oracle服务解释
[本文介绍] oracle不像mysql,安装后之后一个服务,如果mysql连接不上,打开其服务就行.oracle是有多个服务,哪些服务要开,哪些服务没必要开,对新手来说未必不是一个难点.下面对ora ...
- go——切片
切片(slice)可以看作一种对数组的包装形式,它包装的数组为该切片的底层数组.反过来讲,切片是针对其底层数组中某个连续片段的描述,下面的代码声明了一个切片类型的变量: var ips = []str ...
- Spring Web MVC 随笔
1.ContextLoaderListener 对于使用Spring的Web应用,无需手动创建Spring容器,而是通过配置文件声明式地创建Spring容器.可以直接在web.xml文件中配置创建Sp ...
- Linux工作管理 jobs、fg、bg、nohup命令
概述 在Linux 中我们登陆了一个终端,已经在执行一个操作,可以通过一定的操作或命令在不关闭当前操作的情况下执行其他操作. 例如,我在当前终端正在 vi 一个文件,在不停止 vi 的情况下,如果我想 ...
- Linux下代理服务器(proxy)配置
Linux下有很多程序都只有命令行接口,对于这类程序,它们通过代理服务器(proxy)访问网络的方式也不尽相同.在本文中Easwy总结了一些常用Linux程序配置代理服务器的方法. [ 通用代理服务器 ...
- 使用Linq to XML 修改app.config
使用其他的方法修改app.config无效.而且修改的是*.vshost.exe.Config,程序运行时正常,关闭之后就还是原来的值. Configuration configuration = C ...
- 0927-转载:SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
这篇文章暂时只对框架中所要用到的配置文件进行解释说明,而且是针对注解形式的,框架运转的具体流程过两天再进行总结. spring+springmvc+mybatis框架中用到了三个XML配置文件:web ...
- Spring_事务(2)
- window下安裝redis服務
一.下载windows版本的Redis github下载地址:https://github.com/MicrosoftArchive/redis/releases/tag/win-3.2.100 ...