ZOJ 3212 K-Nice(思维)

Android14_MTK调试LCD屏功能 android14 MTK平台调试LCD屏 阅读详情


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


Author: ZHUANG, Junyuan

Source: The 6th Zhejiang Provincial Collegiate Programming Contest


题意:若一个数等于其相邻四数加和,我们就称它为nice数,现要求我们构建一个n*m的矩阵,其中恰好有n个nice数。


#include<bits/stdc++.h>
using namespace std;
int a[20][20];
int main()
{
    int t;
    scanf("%d",&t);
    int n,m,k;
    while(t--)
    {
        scanf("%d%d%d",&n,&m,&k);
        memset(a,0,sizeof(a));
        int cnt=1,flag=0;
        k=(m-2)*(n-2)-k;
        for(int i=0;i<n-1;i++)
        {
            for(int j=1;j<m-1;j++)
            {
                if(cnt<=k)
                {
                    a[i][j]=cnt++;
                }
                else flag=1;
            }
            if(flag)
                break;
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                printf("%d%c",a[i][j],j<m-1?' ':'\n');
            }
        }
    }
}


在 LangGraph 中集成 Skills 增强智能体能力 LangGraph 的核心是通过**状态机 + 节点(Node) + 工具(Tool)**来编排智能体流程,你可以把 Skills 理解为“封装好的工具或可复用的任务流”,下面是一套可落地的集成方案。 阅读详情

相关推荐

Airsim动态 | 安装ROS包装器(AirSim ROS Wrapper)

本期内容我们将带来在Airsim环境下使用ROS Wrapper的相关教程,以下是AirSim客户端库上的一些ROS Wrapper相关配置。 一、启动 以下步骤适用于 Linux 系统。如果是在 Windows 上运行 AirSim,可以使用 Windows Subsystem for Linux (WSL) 来运行 ROS 包装器,如果不想在主机上安装ROS相关工具,也可以使用Docker容器进行安装。请检查下方内容并按照需求安装,具体内容可以参照最后网址。 如果您的默认 GCC 版本不是8或更高版.

AMOVLAB(阿木实验室) 1776

zoj 3212 K-Nice(数学题)

zoj 3212 K-Nice(数学题)

1427

R语言的下载、安装及环境配置(Rstudio&VSCode)

R for Windows是一个免费的用于统计计算和统计制图的优秀工具,是R语言开发工具。它拥有数据存储和处理系统、数组运算工具(其向量、矩阵运算方面功能尤其强大)、完整连贯的统计分析工具、优秀的统计制图等功能。提供的图形界面,可以在其中访问控制台、创建脚本或安装其他软件包。

zegeai的博客 2万+

【城会玩系列】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

mengxiang000000 777

W5500 MACRAW模式实战:在ESP32上抓取并解析原始以太网数据包

本文详细介绍了如何在ESP32开发板上使用W5500芯片的MACRAW模式捕获和解析原始以太网数据包。通过硬件连接指南、代码实现示例和协议解析技巧,帮助开发者深入理解网络通信底层机制,实现网络嗅探和自定义协议开发等高级应用。

weixin_42520573的博客 418

k8s 100个高频面试题

以下是 100 个 Kubernetes(k8s)高频面试题及其答案,涵盖了 Kubernetes 的核心概念、架构、组件、工作原理以及实际应用。答案:Master 节点组件:API Server:提供 RESTful API 接口,用于与集群交互。etcd:分布式键值存储,用于存储集群的配置数据和状态信息。Controller Manager:运行各种控制器进程,负责维护集群的状态。Scheduler:负责将 Pod 调度到合适的节点上运行。Worker 节点组件:Kubelet:运行在每个节点上的代理,

wankll的专栏 2778

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

宝树啊宝树 521

SecOC专题之新鲜值TripCnt

本系列为一步步拆解新鲜值的分发及管理而撰写文章属于原创,根据自身开发经验及理解撰写,若有错误请指出Trip Counter是新鲜值中变化最慢的一个part,并且自增到最大值时,会从头开始翻转计数。Trip Counter需要收发双方都保存,由于其变化较慢,所以不会经常进行同步该值。这就要求开发过程中保证每次对该值的读写必须要正确。

qq_22969363的博客 1154

ZOJ-3212-K-Nice【6th浙江省赛】【构造】

ZOJ-3212-K-Nice

Linoy 1140

ABAP GIT 作用介绍

总结起来,ABAPGit 是一个强大的工具,它通过将 SAP ABAP 项目与 Git 版本控制系统集成,大大提高了代码管理的效率和团队协作的质量。在 ABAPGit 出现之前,ABAP 代码的版本控制和团队之间的协作主要依赖于手工操作或者是 SAP 自带的版本控制工具,这些方式效率低下,且难以实现高效的代码管理。使用 ABAPGit,SAP 项目团队不仅可以提高代码管理的效率和质量,还可以通过 Git 的强大功能实现高效的团队协作和代码审查。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 839

一文搞懂自适应激光控制技术,开启光学新时代

自适应激光控制技术作为现代光学领域的关键技术,以其独特的原理和高效的工作机制,在科研、工业等众多领域展现出了巨大的应用价值。通过对激光波前的实时测量与补偿,它成功克服了激光在传输和应用过程中面临的诸多挑战,显著提升了激光的光束质量和应用效果。在科研领域,它助力天文观测突破大气湍流的限制,让我们得以更清晰地窥探宇宙的奥秘;在激光核聚变研究中,为实现高效的核聚变反应提供了关键支持,为解决能源问题带来了新的希望。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 2529

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

Rachel Zhang的专栏 2660

PointNet++改进策略 :模块改进 | x-Conv | PointCNN, 结合局部结构与全局排列提升模型性能

这篇论文介绍了一种名为PointCNN的方法,旨在从点云(point cloud)数据中学习特征。传统卷积神经网络(CNN)在处理规则网格数据(如图像)时非常有效,但由于点云是无序且不规则的,直接在其上应用卷积操作会导致形状信息丢失,并对点的排列顺序敏感。为了解决这一问题,论文提出了一种X-Conv操作。该方法通过学习一种来重新排列点云中的点并加权输入特征。然后,将典型的卷积操作应用于转换后的特征。这种方法将传统的 CNN 扩展到点云特征学习,并命名为PointCNN。

u012901740的博客 2300

ZOJ - 3212 K-Nice 思维 推公式

ZOJ - 3212 K-Nice 题意: 给你 n,m 和 k,要你输出一个矩阵n行m列,它有 k 个nice 元素。一个元素的 上下左右 四个元素的和与这个元素的值相同,则称这个元素为一个nice。 nice元素必须是非边上的元素(题目没说。。。)。 思路: 为了方便我们可以只用 0和1 两种数字来填矩阵。观察发现: 当 k=(n-2)*(m-2)时,矩阵中非边上的位置都需要满足条...

没有梦想何以远行 273

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

ZOJ 3212 K-Nice (K)

K-NiceTime 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 ...

weixin_30235225的博客 139

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

zoj How Many Sets II 3557 (组合数学&&转换)好题

How Many Sets II Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a set S = {1, 2, ..., n}, number m and p, your job is to count how many set T satisfies the following condition:

yanghui07216的博客 620

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

zoj 3212

很简单的题目,不要想多就行 #include #include using namespace std; int main() { int num[16][16]; int t,sum,n,m,j,k,i; scanf("%d",&t); while(t--) { scanf("%d%d%d",&n,&m,&k); for(i=0;i<n;i++) { for(

默、 604

省赛热身赛之 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...

weixin_34015566的博客 156

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

Puya的博客 407

zoj 1871 steps 题解(数学)

#数论第一练# 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86703#problem/A 题意:给定两个数a,b,问最少执行多少步操作能从a变到b,操作是:每一步可以比前一个数字加一,或者不加,或者减一,必须保证第一步和最后一步都是加1或者减1。 思路:基本是个找规律题,多写几组容易发现,存在两个临界点,一个是前n项

li1004133206的专栏 559

zoj 3629 数学杂题

//#pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include #include #include #include using namespace std; #define ls(rt) rt*2 #de

Pilgrim 1109

【ZOJ - 3212 】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 elemen...

xuanweiace的博客 684

CF#877 B. Nikita and string(思维,暴力)

B. Nikita and string time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Nikita found the string contai

xiaotuji的博客 1242

CF#798 B. Mike and strings(思维)

B. Mike and strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has n strings s1, s2, ..., sn each

xiaotuji的博客 1108

CF#798 C. Mike and gcd problem(思维)

C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..

xiaotuji的博客 947

CSU 1009 抛硬币(贪心)

1009: 抛硬币 Submit Page     Summary    Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitted: 1104     Solved: 346     Description James得到了一堆有趣的硬币,于是决定用这些硬币跟朋友们玩个小游戏。在一个N行M列的表格上,每一个

xiaotuji的博客 870
上一篇: CSU 1009 抛硬币(贪心)
下一篇: CF#348 A. Mafia(二分,思维)
信鸦
博客等级 码龄10年 10粉丝 133原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值