历届试题 剪格子 (DFS,java)

Java算法篇【剪格子】 阅读详情

  历届试题 剪格子  

时间限制:1.0s   内存限制:256.0MB
   
问题描述

如下图所示,3 x 3 的格子中填写了一些整数。

+--*--+--+
|10* 1|52|
+--****--+
|20|30* 1|
*******--+
| 1| 2| 3|
+--+--+--+

我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。

本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使得这两个区域的数字和相等。

如果存在多种解答,请输出包含左上角格子的那个区域包含的格子的最小数目。

如果无法分割,则输出 0。

输入格式

程序先读入两个整数 m n 用空格分割 (m,n<10)。

表示表格的宽度和高度。

接下来是n行,每行m个正整数,用空格分开。每个整数不大于10000。

输出格式
输出一个整数,表示在所有解中,包含左上角的分割区可能包含的最小的格子数目。
样例输入1
3 3
10 1 52
20 30 1
1 2 3
样例输出1
3
样例输入2
4 3
1 1 1 1
1 30 80 2
1 1 1 100
样例输出2
10

题目链接:http://lx.lanqiao.cn/problem.page?gpid=T27
解题思路:DFS从左上角的格子出发,只朝前后左右四个方向走,每个格子的值累加,得到的总值满足条件时,接下来判断剪开后是否为“两部分”。选取一个没有被选中的格子进行DFS,看连在一起的格子数目是否为剩余的未被选中的格子数目,如果一致,说明成功找到一种方案,更新ans为最小值。

代码如下:
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main{

	public static int[] a[]=new int[12][12];
	public static boolean[] vis[] =new boolean[12][12];
	public static boolean[] visok[] = new boolean[12][12];
	public static int n,m,sum,ans,sp;
	public static int dx[] = {0,-1,0,1};
	public static int dy[] = {-1,0,1,0};
	
	public static boolean ok(int x,int y,int step){
		if(step==sp){
			return true;
		}
		for(int i=0;i<4;i++){
			int xx = x+dx[i];
			int yy = y+dy[i];
			if(xx<0 || yy<0 || xx>=n|| yy>=m || vis[xx][yy] || visok[xx][yy] ){
				continue;
			}
			visok[xx][yy] = true;
			sp++;
			if(ok(xx,yy,step)){
				return true;
			}
		}
		return false;
	}
	
	public static void DFS(int x,int y,int cur,int cnt){
		if(cur==sum){
			boolean f = false;
			int sx=n,sy=m;
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++ ){
					if(!vis[i][j]){
						f=true;
						sx=i;
						sy=j;
						break;
					}
				}
				if(f){
					break;
				}
			}
			for(int h=0;h<12;h++){
				for(int k=0;k<12;k++){
					visok[h][k] = false;;
				}
			}
			sp=1;
			if(ok(sx,sy,n*m-cnt)){
				ans = Math.min(ans,cnt);
			}
			return;
		}
		for(int i=0;i<4;i++){
			int xx = x+dx[i];
			int yy = y+dy[i];
			if(xx<0 || yy<0 || xx>=n|| yy>=m || vis[xx][yy] || cur+a[xx][yy]>sum){
				continue;
			}
			vis[xx][yy] = true;
			DFS(xx,yy,cur+a[xx][yy],cnt+1);
			vis[xx][yy] = false;
		}
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		m = sc.nextInt();
		n = sc.nextInt();
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				a[i][j] = sc.nextInt();
				sum += a[i][j]; 
			}
		}
		if(sum % 2!=0){
			System.out.println("0");
			return;
		}
		sum = sum/2;
		ans=Integer.MAX_VALUE;
		for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				vis[i][j] = false;
			}
		}
		vis[0][0]=true;
		DFS(0,0,a[0][0],1);
		if(ans==Integer.MAX_VALUE){
			System.out.println("0");
		}else{
			System.out.println(ans);
		}
	}
			
}


蓝桥杯 - 历届试题 剪格子 问题描述 如下图所示,3 x 3 的格子中填写了一些整数。 +--*--+--+ |10* 1|52| +--****--+ |20|30* 1| *******--+ | 1| 2| 3| +--+--+--+ 我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使 阅读详情

相关推荐

国产数据库安装部署说明

国产数据库安装部署说明

weixin_38203586的博客 907

【蓝桥杯】历届试题 剪格子(深度优先搜索dfs、广度优先搜索bfs)

对于本题而言,可将其简化为:把一个数字阵分为两部分,使这两部分的数值之和一致,并将这两部分中格子数量最少的那个输出。这就迫使我们思考两类搜索算法各自的特点: - dfs 主要的着重点在于“能不能将这个格子阵分为相同的两个部分”,即“能不能找到” - bfs 主要的着重点在于“如果存在两个部分的和相等,输出第一个找到的(即最短的)”

酱懵静的博客 2509

鸿蒙子系统解读-分布式软总线子系统初步研究(下)

鸿蒙子系统解读-分布式软总线子系统初步研究(下) 本文作者:江苏润和软件股份有限公司 郎建中 3.2. 数据传输 上一节我们看了PublishService()函数的代码实现过程。被发现端发布服务后,软总线回调发布成功的函数中,被发现端需要使用CreateSessionServer()来创建会话的服务器等待发现端的连接创建会话。下面我们就来分析CreateSessionServer()函数的实现过程。 数据传输部分的代码位于foundation/communication/services/softbus

weixin_47070198的博客 3088

蓝桥杯 历年真题 剪格子(dfs+回溯+剪枝)

题意:从左上角开始把给的格子分成两部分,两部分的和相同。问最少的左上角格子数。 思路:bfs。 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int map[12][12],n,m; int vis[12][12]; int dx[]={0,0,1,-1...

DeathYmz的博客 1546

TP4056锂电池充电电路设计原理与工程实践

锂离子电池充电管理是嵌入式电源系统的核心基础技术,其本质是通过恒流恒压(CC/CV)控制策略,匹配电池电化学特性以实现安全、高效、长寿命充放电。TP4056作为典型线性充电IC,以精简外围实现预充、恒流、恒压及自动截止全周期管理,但受限于线性拓扑的热耗散特性,必须协同散热设计、电阻精度选型与PCB布局进行系统级优化。该方案广泛应用于STM32智能小车、便携传感器节点等3.7V单节锂电供电场景,兼顾成本、可靠性与工程可实施性,是入门嵌入式硬件电源设计的关键实践范例。

weixin_36064575的博客 219

AS7262六通道可见光传感器:从光谱原理到物联网色彩检测实战

光谱检测是嵌入式感知领域的关键技术,其核心原理是通过特定波长的滤光片分离光线并转换为电信号,从而实现对环境光或物体反射光的成分分析。这项技术的价值在于将复杂的光学分析简化为可编程读取的数字信号,极大降低了色彩检测在物联网和智能设备中的应用门槛。在智能农业、工业分拣、环境监测等场景中,精确的光谱数据能够驱动自动化决策,例如评估植物光照条件或识别物料颜色。本文以Adafruit AS7262传感器为例,深入解析其基于硅干涉滤光片的六通道设计,并通过Arduino与Python实战,演示如何快速构建从数据采集到可

weixin_28738173的博客 595

蓝桥杯Python历届真题04-剪格子(dfs深度优先搜索,保姆级注释,不懂来打我~)

时间限制:1.0s 内存限制:256.0MB 问题描述: 如图所示,3 x 3 的格子中填写了一些整数。 我们沿着图中的红色线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使得这两个区域的数字和相等。 如果存在多种解答,请输出包含左上角格子的那个区域包含的格子的最小数目。 如果无法分割,则输出 0。 输入格式: 程序先读入两个整数 m n 用空格分割 (m,n< 10)...

weixin_52572034的博客 1533

YoloV10改进策略:卷积篇|基于PConv的二次创新|附结构图|性能和精度得到大幅度提高(独家原创)

在PConv的基础上做了二次创新,创新后的模型不仅在精度和速度上有了质的提升,还可以支持Stride为2的降采样。改进方法简单高效,需要发论文的同学不要错过!

m0_47867638的博客 1094

JAVA算法练习(7):剪格子

题目来源取自蓝桥杯 java 组

jc15274630894的博客 319

喷涂机器人系列编程:ABB IRB 5500_(2).ABB IRB 5500喷涂机器人系统架构与组件

ABB IRB 5500喷涂机器人系统不仅在性能上表现出色,而且在安全和维护方面也提供了全面的解决方案。通过本文的详细介绍,希望读者能够更好地理解和掌握这一系统的架构和功能,为实际应用提供有力支持。

zhubeibei168的博客 776

SpringBoot中使用FastJson解析Json数据

场景 1.SpringBoot默认配置的是Jackson。 2.项目搭建专栏: https://blog.youkuaiyun.com/BADAO_LIUMANG_QIZHI/column/info/35688 实现 引入fastJson的依赖 <!-- fastjson的依赖 --> <dependency> <groupId>com.alibab...

BADAO_LIUMANG_QIZHI的博客 4140

java 剪格子,歷屆試題 剪格子 (DFS,java)

問題描述如下圖所示,3 x 3 的格子中填寫了一些整數。+--*--+--+|10* 1|52|+--****--+|20|30* 1|*******--+| 1| 2| 3|+--+--+--+我們沿着圖中的星號線剪開,得到兩個部分,每個部分的數字和都是60。本題的要求就是請你編程判定:對給定的m x n 的格子中的整數,是否可以分割為兩個部分,使得這兩個區域的數字和相等。如果存在多種解答,請輸...

weixin_28691003的博客 109

Linux安装Docker(图文解说详细版)

第一步,下载docker 下载地址: https://download.docker.com/linux/static/stable/x86_64/ 这次的演示我们使用docker-18.06.3-ce.tgz 这个版本 第二步,上传到云服务器上面 使用rz命令上传或者fltp工具进行上传 第三步,解压文件 第四步,将解压出来的docker文件复制到 /usr/bin/ 目录下 这么做的目的是将docker交给linux自己去管理,类似spring中的ioc(猜测,非正经知识) cp docker

编码人生 1万+

蓝桥杯 历届试题 剪格子 解题报告(dfs+ 回溯)

原 蓝桥杯 历届试题 剪格子 解题报告(dfs+ 回溯) 2017年04月27日 18:57:05 o0Roy 阅读数:362 &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;/div&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;

上帝掷骰子吗? 296

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

蓝桥杯 历届真题之剪格子(dfs)

一直都害怕搜索,,不知道为什么(明明那么好用==),然后试探地敲一敲,然后就过了。别怕啊啊啊然后这题用的是dfs 开始想的是能不能用bfs 写呢?因为bfs比较简单,又好想,然后又没有递归,直接一个 队列,四个方向,能走的就进队,最后第一个出来的,出来进去就好了嘛。但是在写的时候,要不要标记数组?要的话,那第一种情况走的,第二种情况就不能走了,若第二种路径才是正确的呢,那怎么办?不要的话,走回

bllsll 555

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

蓝桥杯 历届试题 剪格子 简单的DFS~~注意输入有陷阱~~

如下图所示,3 x 3 的格子中填写了一些整数。 +--*--+--+ |10* 1|52| +--****--+ |20|30* 1| *******--+ | 1| 2| 3| +--+--+--+ 我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使得这两个区域的数字和相等。 如果存在多种解答,请输出包含左上角格子的那个区域包含的格子的最小数目。 如果无法分割,则输出 0。 输入格式 程

Lionel 2016

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Java实现 蓝桥杯 历届试题 剪格子

问题描述 如下图所示,3 x 3 的格子中填写了一些整数。 +--*--+--+ |10* 1|52| +--****--+ |20|30* 1| *******--+ | 1| 2| 3| +--+--+--+ 我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使得这两个区域的数字和相等。...

南 墙 1万+

蓝桥杯 历届试题 剪格子 java

Prev4 历届试题 剪格子 题目如下: 这道题看似挺简单,能看出就是用dfs来搜索的,而且通过"包含左上角的分割区"这句话可以得知此次dfs应该以左上角为起点 而且可以从描述得到,我们搜索格子的结束标志就是搜索到的格子的权值等于所有格子权值的一半 那么就好写了,还要注意的就是我们搜索到的那一部分肯定是一部分的,但我们把这部分去掉之后,剩下的格子是不是还只有一部分?这是需要判断其的连通性的。但其实这道题数据很水,才三组,所以你不考虑这个也能过,但还是严谨点比较好,有同学想练连通性的题的话可以练第九届的全球

我命由己不由天 349

历届试题 剪格子  (DFS)

历届试题 剪格子 时间限制:1.0s 内存限制:256.0MB 问题描述 如下图所示,3 x 3 的格子中填写了一些整数。 +--*--+--+ |10* 1|52| +--****--+ |20|30* 1| *******--+ | 1| 2| 3| +--+--+--+ 我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就...

qq_42794545的博客 277

蓝桥杯【历届试题 剪格子】 java版

利用深度优先搜索 import java.util.Scanner; public class Main{ //存储格子 static int[][] map; //是否已访问 static int[][] marked; //查找当前格子相邻的格子 static int[][] connect = {{1,0}, {-1,0}, {0,1...

8-0416 537

历届试题 剪格子

问题描述 如下图所示,3 x 3 的格子中填写了一些整数。 ±-–±-+ |10 1|52| ±-***–+ |20|30 1| *******–+ | 1| 2| 3| ±-±-±-+ 我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使得这两个区域的数字和相等。 如果存在多种解答,请输出包...

飞驰人生 458

蓝桥杯 Java 历届试题 剪格子

历届试题 剪格子 资源限制 时间限制:1.0s 内存限制:256.0MB 问题描述 如下图所示,3 x 3 的格子中填写了一些整数。 ±-–±-+ |10 1|52| ±-***–+ |20|30 1| *******–+ | 1| 2| 3| ±-±-±-+ 我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是...

weixin_44570019的博客 259

蓝桥杯 历届试题 剪格子(DFS 回溯)

文章目录问题描述:解题思路:代码实现: 问题描述: 如下图所示,3 x 3 的格子中填写了一些整数。 +--*--+--+ |10* 1|52| +--****--+ |20|30* 1| *******--+ | 1| 2| 3| +--+--+--+ 我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使得这两个区域的数字和相等。 如果存在多种解答,请输出包含左上角格子的那个区域包含的格子

覃会程的博客 277
上一篇: FZU Problem 2150 Fire Game (BFS,java)
下一篇: 382. Linked List Random Node (蓄水池抽样,java)
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值