zoj 3822 (2014 牡丹江区域赛 D) Domination

SecureCRT串口连接保姆级教程:从驱动安装到波特率设置(附常见问题解决) 本文提供SecureCRT串口连接的保姆级教程,涵盖从USB转串口驱动安装、端口识别到波特率等核心参数设置的完整流程。针对连接失败、乱码、键盘输入无响应等高频问题,给出了深度排查与解决方案,帮助网络与嵌入式开发新手快速掌握串口调试技能。 阅读详情

        题意:一个n*m的棋盘,每天等概率随机在一个空位上放一个棋子,直到每行每列都至少有一个棋子。问这个过程持续天数的期望。

        思路:概率dp。如果想到了如何表示状态,剩下的就不难了。dp(i,j,k)表示出现 i行中有棋子,j列中有棋子,一共有k个棋子 这种情况的概率。其中i=0~n,j=0~m,k=0~n*m-min(n,m)+1。初态是dp(0,0,0)=1.0。状态转移有4种情况,即放下棋子后没有新增的行列,仅增加行,仅增加列,同时增加行列,具体状态转移见代码。最后按照期望的定义算一下即可。


#include <iostream>       
#include <stdio.h>       
#include <cmath>       
#include <algorithm>       
#include <iomanip>       
#include <cstdlib>       
#include <string>       
#include <memory.h>       
#include <vector>       
#include <queue>       
#include <stack>       
#include <map>     
#include <set>     
#include <ctype.h>       
#include <sstream>   
#define INF 1000000000   
#define ll long long   
#define min3(a,b,c) min(a,min(b,c))   
#define max3(a,b,c) max(a,max(b,c))   
#define MAXN 100010   
     
using namespace std;     

double dp[52][52][2510];

int main(){
	int n,m;
	int t; cin>>t;
	while(t--){
		cin>>n>>m;
		//init
		for(int k=0;k<=n*m;k++){
			for(int i=0;i<=n;i++){
				for(int j=0;j<=m;j++){
					dp[i][j][k]=0.0;
				}
			}
		}
		dp[0][0][0]=1.0;
		//
		double ans=0.0;
		int end=n*m-min(n,m)+1;
		for(int k=0;k<=end;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					dp[i+1][j+1][k+1]+=dp[i][j][k]*(n*m-i*m-j*n+i*j)/(n*m-k);
					dp[i+1][j+1][k+1]+=dp[i][j+1][k]*( (n-i)*(j+1) )/(n*m-k);
					dp[i+1][j+1][k+1]+=dp[i+1][j][k]*( (m-j)*(i+1) )/(n*m-k);
					if(!(i+1==n&&j+1==m))dp[i+1][j+1][k+1]+=dp[i+1][j+1][k]*((i+1)*(j+1)-k)/(n*m-k);
					else ans+=dp[n][m][k]*k;
				}
			}
		}
		
		printf("%.10lf\n",ans);
	}
	return 0;
}



网络攻防——kali操作系统基本使用 主要介绍如何搭建kali虚拟机,然后介绍了一个简单的攻击方法,切记,网络恶意攻击属于违法行为 阅读详情

相关推荐

区块链入门:用账本、乐高和三台旧电脑讲懂分布式账本

区块链是一种去中心化的分布式账本技术,其核心原理是通过密码学哈希、共识机制和链式结构实现数据不可篡改与多方共同验证。它不依赖单一中心,而是将交易记录同步复制到多个节点,依靠数学规则而非人工信任达成一致,从而在数字世界构建可验证的信用基础设施。这种‘集体见证’模式显著提升了系统抗单点故障与人为干预的能力,广泛应用于供应链溯源、数字身份、教育管理及公益透明等需强信任保障的场景。本文以账本类比、乐高拆解和Ganache实操为线索,面向零基础读者通俗解析哈希值、挖矿与智能合约等关键概念。

weixin_30517215的博客 274

zoj 3822 Domination 概率dp 2014牡丹江站D题

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his fr

smz436487的专栏 1391

网络工程系统CAD图:从设计到落地的关键技能与实战指南

网络工程并不只是配置路由器和交换机,真正的核心在于将设计方案转化为可施工的物理图纸。网络工程系统CAD图正是连接逻辑设计与物理世界的桥梁,它涵盖综合布线、信息点布置、桥架路由、弱电间规划等关键内容。理解并掌握这套图纸体系,是网络工程师从基础设备调试走向项目主导者、弱电总工乃至网络架构师的重要分水岭。在园区网、数据中心、智能楼宇等真实场景中,一套规范的系统CAD图直接决定了施工质量、验收效率与后期运维的可靠性。本文从基础概念出发,拆解图纸的组成层次、绘制流程和软件工作流,并结合学习路线与就业方向,帮助初学者建

weixin_33860553的博客 390

ZOJ3822 ACM-ICPC 2014 亚洲区域赛牡丹江赛区现场赛D题Domination 概率DP

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his frie

Puyuacm的专栏 2634

MCAL配置之CAN模块及源码分析

该文章详细解析了Autosar中MCAL配置里的CAN模块,详细分析了重要的配置选项,并对CAN的发送和接收函数进行了剖析。

u013624141的博客 1416

搞定最强大模型Gemini学生订阅,白嫖一年,包教包会

白嫖现在最强大模型

BUG猿的博客 2万+

zoj 3822 Domination 概率DP

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with hi

Dikea's Blog 597

Python实战日志_P4_图书馆Web API服务

目标:使用Flask将图书馆系统升级为RESTful API服务,掌握Web开发基础难度:⭐⭐⭐⭐☆预计学习时间:75分钟前置要求:已完成第3篇《个人图书馆管理系统》

qq_39436086的博客 83

ZOJ 3822 Domination /2014牡丹江现场赛D题 (dp)

题意: 给你一个NXM

u012659423的专栏 869

瑞数jsvmp算法还原流程讲解

​ 又是很久没写文章了,今天水一篇文章吧,鉴于之前有看到过别人的文章被警告的案例,所以这篇文章就仅写一下还原瑞数vmp的大概流程吧(仅记录下自己还原的思路)

博客 6607

TenserRt平台SMOKE 3D目标检测部署完整教程:从理论到实践

本教程详细介绍了在RK3588平台上部署SMOKE 3D目标检测模型的完整流程。SMOKE是一种创新的单阶段单目3D检测方法,通过关键点估计直接预测3D目标信息,有效解决了深度信息缺失等挑战。文章从理论基础出发,解析了SMOKE的核心算法和网络架构,包括DLA-34主干网络和关键点中心化策略。同时提供了详细的Docker环境配置、模型导出到ONNX格式的实践指南,以及TensorRT引擎构建和性能优化的关键技术要点。该教程为开发者在嵌入式平台上实现高效3D目标检测提供了完整的技术参考。

LXY_LOVE36的博客 371

zoj3822 Domination

题意:n*m的棋盘,每天放一个棋子,直到每行每列都有棋子时不再放,问所放棋子个数的期望。 分析:概率dp,dp[a][b][k]表示用k个棋子占据a行b列还需棋子的期望,具体转移看代码。 #include #include #include #include #include #include #include #include #include #define inf 1000000000

Every day 485

Megatron-LM中的TP、PP、DP、SP、CP并行

SP主要优化的是激活内存,它沿序列维度切分部分激活,适用于较短序列并行。CP主要解决的是长序列的显存问题,它沿序列维度切分所有激活和输入,并且对注意力机制也进行并行处理。二者可以组合使用,特别是当 TP > 1 并且需要处理长序列时,通过启用 SP 和 CP 可以最大化地优化内存使用和加速计算。

u013250861的博客 861

zoj 3822 Domination(2014牡丹江区域赛D题)

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his frie

ACway的专栏 2026

Statistics and Machine Learning Toolbox

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

深度学习工具包 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")

ZOJ 3822 Domination 概率DP 2014年ACM_ICPC亚洲区域赛牡丹江现场赛D题

题目大意: 就是现在有一个N*M的棋盘(1 大致思路: 这题同步赛的时候没感觉, 现在做发现就是一个水题, 当时还是太弱了... 状态转移方程见代码注释吧.. 代码如下: Result  :  Accepted     Memory  :  51276 KB     Time  :  1750 ms /* * Author: Gatevin * Created

Gatevin的专栏 2926

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

zoj 3822 Domination(2014牡丹江区域赛D称号)

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his ...

weixin_34186128的博客 101

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

zoj 3822 Domination(2014牡丹江区域赛D题) (概率dp)

3799567 2014-10-14 10:13:59 Accepted 3822 C++ 1870 71760...

weixin_33774615的博客 72

学习率预热与GradualWarmupScheduler:PyTorch训练防loss尖峰

在深度学习模型训练中,学习率设置直接影响收敛稳定性与最终精度。随机初始化初期,梯度噪声和BatchNorm统计量不稳定容易导致loss尖峰甚至NaN,此时需要一种平滑起步策略。学习率预热(warmup)通过先小步幅试探再逐步提升,为优化器建立可靠的梯度统计和BN缓冲。PyTorch中可通过GradualWarmupScheduler实现线性预热与余弦退火的无缝交接,既保护早期训练,又为后续调度提供统一入口。本文从实现原理、代码拆解到调参建议,帮助你在实际工程中稳定训练过程并提升模型收敛效果。

weixin_34183910的博客 413

ZOJ3822 ACM-ICPC 2014 亚洲区域赛牡丹江赛区现场赛D题Domination 概率DP(两种解法)

题目地址:点击打开链接 这道题有两种做法,第一种是直接求期望,类似于poj 2096 区别在于这个步数有限。所以要迭代步数。 #include #include #include #define maxn 55//这里刚开始写成了50+10 那么maxn*maxn就会小很多wa了一次 using namespace std; double dp[maxn][maxn][maxn*maxn

gg_gogoing的专栏 1018

ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)...

Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N rows ...

weixin_30670151的博客 176

zoj3822 Domination 2014亚洲区域赛牡丹江站

Time Limit: 8000MS   Memory Limit: 131072KB     Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. Wh

、Poppy 557

2014ACM/ICPC亚洲区域赛牡丹江站现场赛-D ( ZOJ 3822 ) Domonation

题目链接: Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays

sxk 1405

ZOJ3822 ACM-ICPC 2014 亚洲杯赛事现场牡丹江司D称号Domination 可能性DP

Domination Time Limit:8 Seconds Memory Limit:131072 KB Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his ...

weixin_30549657的博客 82

ZOJ 3822 Domination(2014牡丹江Regional D题)

人家当场切掉的题,表示在场外做zoj还是要别人提醒dp数组的i,j,k分别表示什么含义才能AC... 下周鞍山之行无限堪忧TAT~ 题目大意:有一个n * m的棋盘,每天放入一个棋子,当所有行和列都存在棋子的时候,就是一种符合的情况。 然后这种情况的值就是它的天数(也就是棋子个数),问所有符合的情况的期望值。 dp[i][j][k]表示放i个棋子,能盖住j行k列的概率。 由d...

weixin_30567471的博客 144

ZOJ 3822 Domination

解题思路:  简单的DP , 用DP[ i ] [ j ] [ k ] 表示第 i 天 覆盖了

蘑菇--走在通往梦想的道路上。 676

ACM 2014 牡丹江区域赛 D - Domination(期望dp)

题目大意:         题意:n*m的格子里放棋子,一次只能放一个,问当棋盘的所有列和所有行中都至少有一个棋子时的期望次数。 题解:        看到这个题的时候,感觉和做期望专题做过的CodeForces - 398B 和 poj2096 很类似,于是就按照印象中这两道题的做法去写了,但是写完之后却总是得不到正确的结构,后来分析之下才发现原来他们是有区别的!      codef...

hxxjxw的博客 315
上一篇: Codeforces Round #272 (Div. 2) C
下一篇: zoj 3829 (2014牡丹江区域赛K) Known Notation
squee_spoon
博客等级 码龄14年 61粉丝 455原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值