CodeForces-50A-Domino piling

react-window 大数据列表和表格数据渲染组件之虚拟滚动 ReactWindow是一个高性能的React虚拟滚动组件库,专门用于高效渲染大型列表和表格数据。它通过“窗口化”技术,仅渲染用户可见区域的内容,大幅提升性能并减少内存消耗。主要特点包括:支持固定/可变大小列表项、多种布局类型(垂直/水平/网格)、轻量级设计(不足5KB)以及平滑的滚动体验。相比传统渲染方式,它能轻松处理成千上万条数据,并提供自动滚动、自适应容器大小等高级功能。与同类库相比,ReactWindow具有更简洁的API和更优的性能表现,是处理大数据量渲染场景的理想选择。 阅读详情
A. Domino piling
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:

1. Each domino completely covers two squares.

2. No two dominoes overlap.

3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.

Find the maximum number of dominoes, which can be placed under these restrictions.

Input

In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).

Output

Output one number — the maximal number of dominoes, which can be placed.

Sample test(s)
input
2 4
output
4
input
3 3
output
4

import java.util.*;

public class DominoPiling {
	public static void main(String[] args) {
		Scanner inScanner = new Scanner(System.in);
		int m = 0, n = 0;
		int count = 0;
		m = inScanner.nextInt();
		n = inScanner.nextInt();
		if (m * n < 2)
			count=0;
		else if (n == 1) {
			count += (m / 2);// downward
		} else {

			int npart = n / 2;
			count += (npart * m);
			if(n%2==1){
				count+=(m/2);// downward
			}
		}
		System.out.println(count);
	}

}
最先写完发现过于麻烦,后经过改进后重写
import java.util.*;

public class DominoPilingPro {
	public static void main(String[] args) {
		Scanner inScanner = new Scanner(System.in);
		int m=inScanner.nextInt();
		int n=inScanner.nextInt();
		if(n%2==0){
			System.out.println(m*n/2);
		}
		else {
			System.out.println(m*n/2+m/2);
		}
	}
}
多余的过程在于对边长的判断。其实,在运用“/”进行除法运算的过程中,整数相除采用了向下取证的方法,因此当边长不及多米诺牌长时,会出现除数比被除数大的情况,因而结果会取0,不需要在开头进行繁杂判断。


ESP32-P4开发板实战:从零配置VSCode环境到点亮MIPI-DSI屏幕(避坑指南) 本文详细介绍了ESP32-P4开发板在VSCode环境下的配置流程,包括SDK安装、idf_component.yml依赖管理,以及MIPI-DSI屏幕驱动的实现方法。通过实战指南帮助开发者避开常见配置陷阱,快速完成从环境搭建到屏幕点亮的全流程,适用于物联网和嵌入式开发场景。 阅读详情

相关推荐

使用gsplat进行3D高斯泼溅的方案

gsplat 不是一个软件,而是一个深度优化CUDA的开源Python库。它的作者是 Nerfstudio 团队,这个团队最出名的项目是 Nerfstudio,是对 NeRFs 方法支持最好的一套框架。据其所述,出于对新一代技术的好奇,他们构建了 gsplat 这个库。它支持 Windows/Linux 两个系统,使用前必须准备好 Nvidia 显卡。跑这个项目真是特别费劲,官方的文档支持不够完善,以至于遇到问题,开发者们都只能在issue区里抱团取暖。

兴趣使然的创作者 2117

CodeForces - 50A Domino piling

A. Domino pilingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rectangular board of M × N squares. Also you are given an unlimite...

YIU 379

Python实战:3种高效方法将txt转csv(附pandas对比测试)

本文针对Python中将txt文件转换为csv格式的需求,深度评测了open()、csv模块和pandas三种主流方法。通过详尽的性能对比测试,从执行效率、内存占用和适用场景等维度提供选型指南,帮助开发者根据数据规模与复杂度选择最高效的转换方案。

weixin_29073241的博客 269

codeforces 50A

http://codeforces.com/problemset/problem/50/A #include<cstdio> #include<iostream> using namespace std; int main() { int n,m,i; while(cin>>m>>n) { if(n%2==0) co...

262

Geneformer实战:如何用Hugging Face Transformers快速搭建单细胞转录组分类模型

本文详细介绍了如何使用Geneformer和Hugging Face Transformers快速搭建单细胞转录组分类模型。通过环境准备、数据预处理、模型加载与配置、训练Pipeline构建等步骤,帮助读者掌握基于Transformer架构的单细胞数据分析技术,提升分类准确率和效率。

rl6adventurer的博客 610

逆向实战:拼多多anti-content加密参数的全链路解析与动态对抗策略

本文深入解析了拼多多anti-content加密参数的全链路生成逻辑与动态对抗策略。通过逆向工程实战,详细拆解了包含设备指纹、用户行为采集和动态密钥生成在内的12个关键环节,并提供了可持续对抗的精准模拟方案和自动化更新机制,帮助开发者有效应对拼多多的反爬体系。

weixin_30687051的博客 167

Codeforces 50A(往矩形里填多米诺骨牌)

A. Domino piling time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a rectangular board of M × N

coco_astrids的博客 1306

晶振匹配电容容值计算方法

在使用晶振时,应仔细参考晶振规格书,以确保正确选择匹配电容,从而获得稳定和精准的时钟源。

aidi1111的博客 4668

codeforces 50A Domino piling(数学水题)

A. Domino piling 点击打开题目 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a rectangular board of M × N

2552

2024届数字IC秋招-华为机试-数字芯片-笔试真题和答案(五)(含2022年和2023年)

此部分包含华为机试真题,方向是数字芯片,内容详细包括设计、验证、后端等,大部分题目给出参考答案。华为机试都是从题库里抽题目,所以这些题目还是很有参考性的,甚至是完全一样,可以搜到的。(题目内容较多,将分开编写几个文章)

qq_42135020的博客 2091

【动态导通电阻】p-GaN HEMTs正向和反向导通下的动态导通电阻

2024年,浙江大学的研究团队通过多组双脉冲测试方法,深入研究了两种商用p-GaN栅极HEMTs在正向和反向导通模式下的动态导通电阻(RON)特性。研究发现,肖特基型p-GaN栅极HEMTs在反向导通时动态RON比正向导通高3%-5%,而混合漏极嵌入栅注入晶体管在反向导通时动态RON降级较轻,降低约10%。此外,随着漏极电流(IDS)的增加,两种器件在反向导通时动态RON先减小后增加,形成“谷底”现象。

荷塘阅色 832

A. Domino piling

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a rectangular board of M × N squares. Also you are

无知的我 3471

从零开始跑通3DGS教程:(五)3DGS训练

本文介绍了在Docker环境中训练3DGS(3D Gaussian Splatting)的方法,属于《从零开始跑通3DGS教程》系列文章的第五部分。主要内容包括:Docker环境准备(基于pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime镜像)、容器内conda环境配置(安装必要依赖和3DGS相关组件)、以及训练命令执行步骤。文章提供了详细的命令行操作流程,帮助读者快速搭建3DGS训练环境。适合在Linux系统、Nvidia GPU环境下使用,完整教程可参考系列文章

诺有缸的高飞鸟的博客 1767

Domino piling_Codeforces_50A

原题链接:http://codeforces.com/problemset/problem/50/A A. Domino piling time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard

MoogleAndChocobo的博客 293

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

CodeForces - 50A Domino piling (贪心+递归)

CodeForces - 50A Domino piling (贪心+递归)题意分析奇数*偶数=偶数,如果两个都为奇数,最小的奇数-1递归求解,知道两个数都为1,返回0。代码#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #i

Pengwill's Blog 618

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Codeforces——50A Domino piling

小声BB 又有简单题了,舒服了舒服了舒服了 题干 time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2

真田伊廉的博客 230

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

codeforces - 50A-Domino piling

You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as m...

轻舟载君不载愁 291

Codeforces 50A - Domino piling

题目: A. Domino piling time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output You are given a rectangular board of M × N squares. Also you are ...

Yuhan的博客 252

codeforces 50A . Domino piling

这个题就是说M*N的大小用2*1的牌铺,最多用多少牌,前提是不能超出这个M*N面积的大小 By qq1095719690, contest: Codeforces Beta Round #47, problem: (A) Domino piling, Accepted, # #include using namespace std; int main() { int n,m,jg;

sinat_35121480的博客 455

Domino piling(CodeForces - 50A)

Domino piling You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so a

ITzz_qqzi的博客 396

codeforces 50A. Domino piling 【贪心】

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a rectangular board of M × N squares. Also you are given an unlimited nu...

肖火柴的火柴盒 327

CodeForces 50A Domino piling

有用的英文单词:overlap 覆盖 entirely 完全地;全部地 restriction 限制。题目大意:给你一个M×N的矩形,让你用2×1的矩形覆盖它,求最多的2×1矩形数量。解题思路:要么全覆盖,要么剩一个,所以为(N*M)/2。

ywzdcj的博客 149

Problem——50A. Domino piling——Codeforces

You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as m...

Foolishman的博客 305

codeforces | java | 50A | Domino piling

【代码】codeforces | java | 50A | Domino piling。

iCling的博客 324

Codeforces--50A--Domino piling

题目描述: You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to plac...

猩猩是个好程序员的博客 546

CodeForces 50 A.Domino piling(水~)

Description给出一个m∗nm*n的区域,问最多可以放多少个2∗12*1的砖Input两个整数m,n(1≤m,n≤16)m,n(1\le m,n\le 16)Output输出最多可以放多少块砖Sample Input2 4Sample Output4Solutionn,mn,m有一个为偶数,显然可以铺满,ans=nm2ans=\frac{nm}{2}n,mn,m均为奇数,显然前n−1n-1列

ZSQ 833
上一篇: java system.out.printf()的使用方法
下一篇: C++与Java变量声明与赋值的区别
Spikerman
博客等级 码龄13年 1粉丝 27原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值