牛客国庆集训派对Day3 - B Tree (树形DP)

从网格剖分到结果外推:一文拆解HFSS快速扫频(Fast Sweep)的底层逻辑与性能调优 本文深入解析了HFSS快速扫频(Fast Sweep)技术的底层逻辑与性能调优方法。通过ALPS算法实现频带外推,快速扫频相比离散扫频和插值扫频能提升3-5倍计算效率,特别适用于天线阵列、微波滤波器等宽频带分析场景。文章详细介绍了算法架构、参数优化策略及工程实践中的精度保障机制,帮助工程师高效完成电磁仿真。 阅读详情

https://www.nowcoder.com/acm/contest/203/B

 

题解

 

 

思路差不多,不过没用那个flag。如果碰到dp[u]+1 % mod ==0的时候。直接重新搜一遍。

#include <vector>
#include <stdio.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
#define LL long long
const LL N = 1e6+6;
const LL mod = 1e9+7;

vector<int>G[N];
LL dp[N],pre[N];
LL ans[N],fdp[N];

void dfs1(LL u,LL p)
{
	pre[u]=p;
	dp[u]=1;
	for(LL i=0;i<G[u].size();i++){
		LL v=G[u][i];
		if(v==p) continue;
		dfs1(v,u);
		dp[u]=dp[u]*(dp[v]+1)%mod;
	}
}

LL qkm(LL a,LL b)
{
	LL ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}


void dfs2(LL u,LL p)
{
	if(p==-1) ans[u]=dp[u];
	else{
		if((dp[u]+1)%mod==0){
			LL cnt=fdp[p]+1;
			for(LL i=0;i<G[p].size();i++){
				LL v=G[p][i];
				if(v==pre[p]) continue;
				if(v==u) continue;
				cnt=cnt*(dp[v]+1)%mod;
			}
			fdp[u]=cnt;
			ans[u]=(cnt+1)*dp[u]%mod;
		}else{
			LL cnt=ans[p]*qkm(dp[u]+1,mod-2)%mod;
			ans[u]=dp[u]*(cnt+1)%mod;
		}
	}
	for(LL i=0;i<G[u].size();i++){
		if(G[u][i]==p) continue;
		dfs2(G[u][i],u);
	}
}


int main()
{
	LL n;
	scanf("%lld",&n);
	for(LL i=1;i<n;i++){
		LL u,v;
		scanf("%lld%lld",&u,&v);
		G[u].push_back(v);G[v].push_back(u);
	}
	dfs1(1,-1);
	dfs2(1,-1);
	for(LL i=1;i<=n;i++){
		printf("%lld\n",ans[i]);
	}
	


}

 

姿态传感器/陀螺仪之ICM-42670-P应用原理图设计 ICM-42670-P采用LGA-14封装,尺寸为2.5x3x0.76毫米,工作电压范围为1.71V至3.6V,支持I3CSM、I2C和SPI串行通信接口。其设计目标是提供高精度、低功耗和小型化的解决方案,以满足消费类和工业应用的需求。ICM-42670-P是一款由TDK InvenSense推出的高性能六轴MEMS运动追踪传感器,集成了3轴陀螺仪和3轴加速度计,适用于多种应用场景,包括可穿戴设备、游戏控制器、无人机、AR/VR设备等。 阅读详情

相关推荐

ANSYS APDL生死单元实战:焊接模拟从入门到精通(附完整命令流)

本文详细介绍了使用ANSYS APDL进行焊接模拟的核心技术——生死单元法。通过一个完整的平板对接焊案例,从原理剖析、模型搭建、命令流编写到移动热源施加和后处理,手把手指导工程师掌握这一动态仿真方法,有效预测焊接过程中的温度场、残余应力与变形。

k6l7m8n9的博客 149

Tree(树形dp)

链接:https://ac.nowcoder.com/acm/problem/19782 来源:牛客网 题目描述 修修去年种下了一棵树,现在它已经有n个结点了。 修修非常擅长数数,他很快就数出了包含每个点的连通点集的数量。 澜澜也想知道答案,但他不会数数,于是他把问题交给了你。 输入描述: 第一行一个整数n (1≤ n ≤ 106),接下来n-1行每行两个整数ai,bi表示一条边 (1≤ ai,bi≤ n)。 输出描述: 输出n行,每行一个非负整数。第i行表示包含第i个点的连通点集的数量对109+7取模的结

qq_45928501的博客 471

【电机学复习笔记】同步电机的特性及参数的求取

同步电机的主要特性包括:空载特性、短路特性、零功率因数负载特性、外特性和调整特性。 基于以上特性我们可以实现: 从空载特性和短路特性求同步电抗的不饱和值和短路比; 从零功率因数负载特性和空载特性确定保梯电抗(定子漏抗)和电枢反应电动势

Pantrick_的博客 2万+

[牛客] Tree-换根dp(预防加法取模导致等0)

链接:https://ac.nowcoder.com/acm/problem/19782 题目:修修去年种下了一棵树,现在它已经有n个结点了。 修修非常擅长数数,他很快就数出了包含每个点的连通点集的数量。 澜澜也想知道答案,但他不会数数,于是他把问题交给了你。 思路是很简单的换根dp,先求出以1为根的值,然后进行撤回操作再换根,这里最要注意的坑点是 dp【v】+1%mod会等于0(加法会导致模等于0),所以我们这里需要特判处理。 #include <iostrea...

lalalzo的博客 256

【UE5】虚幻引擎Gameplay框架

游戏实例(UGameInstance)会在引擎启动时实例化,并保持活跃直至引擎关闭。这是一种管理器类,在游戏中不存在实体,但会追踪数据和运行代码。在联网多人游戏中,游戏实例不会被复制,而是独立存在于服务器以及所有互联的客户端上。所有你希望在关卡加载间保持的内容都应存于游戏实例中。例如,游戏实例是管理游戏保存系统的到地方。游戏实例还可以充当任意数量的 游戏实例子系统 的管理器,这些子系统由游戏实例创建和销毁,并且与游戏实例本身具有相同的生命周期。在线子系统就属于这类子系统。

一个写程序的 1794

交通小白首投TRB就中Oral?我的完整时间线与避坑指南(附Editorial Manager实操截图)

本文详细解析了交通领域新手如何高效完成TRB国际会议投稿的全流程,从选题策略到投稿系统实操,再到评审过程解析和常见误区避坑指南。特别针对初次投稿者提供了实用建议,包括时间规划、选题考量、Editorial Manager系统操作技巧,以及如何应对评审意见。文章还分享了从录用到会议参与的关键步骤,帮助研究者提升投稿成功率。

weixin_27303545的博客 386

刷题记录:牛客NC19782Tree

刷题记录:牛客NC19782Tree

yingjiayu12的博客 389

AppleAccount注册之生成sign

根据日志发现:签名来自于AuthKit的-[AKAppleIDServerResourceLoadDelegate signRequest:withCompletionHandler:]的一个block,这个库是放在共享缓存库里的,找到提前准备好的IDA文件,先去找主方法,根据分析IDA,最后找到了实际生成签名的方法:t1。,接受五个参数,context(之前讲的获取到的客户端证书),bytes(待加密的body字节),length(字节长度),以及两个接受结果的参数,直接进这个方法看,

2503_90751938的博客 1002

牛客国庆集训派对Day3 B(搜索 树形dp)

链接:https://www.nowcoder.com/acm/contest/203/B 来源:牛客网   时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 1048576K,其他语言2097152K 64bit IO Format: %lld 题目描述 修修去年种下了一棵树,现在它已经有n个结点了。 修修非常擅长数数,他很快就数出了包含每个点的连通点集的数量。 澜澜也想知道...

yypurpose的博客 408

【推荐100个unity插件】基于关节物理控制的自行车、电动车、摩托车模拟解决方案——Simple Bicycle Physics

摘要 "简易自行车物理"是Unity的自行车模拟资源包,支持Animation Rigging,实现基于关节物理的自行车控制。兼容所有平台和渲染管线,包含预制体、材质、脚本等资源。核心脚本Bicycle Controller管理自行车物理属性,支持自定义角色设置和移动端控制。安装后,用户可快速配置骑行场景,调整转向、速度、重心等参数,并支持地面贴合、兔跳等功能。适用于开发各类自行车模拟游戏和应用。 (字数:149)

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 1364

【HALCON工业视觉应用探索】08. C#+Halcon视觉引导机器人抓取:从入门到工业级实战(附完整代码+部署指南)

摘要:本文聚焦C#+Halcon在视觉引导机器人抓取领域的落地应用,从新手友好的“二十分钟基础引导系统”切入,逐步深入工业级场景(汽车变速箱壳体抓取)。内容涵盖核心概念(手眼标定原理、坐标转换、机器人通信协议)、完整技术流程(图像采集→目标定位→标定转换→机器人执行→结果反馈)、工业级代码实现(多目标识别、智能抓取策略、实时状态监控),以及现场部署关键技巧(硬件选型、通信配置、精度优化)。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 1263

牛客国庆集训派对Day3 B-Tree (树上包含某个节点的连通子集个数)

链接:https://www.nowcoder.com/acm/contest/203/B 来源:牛客网   题目描述 修修去年种下了一棵树,现在它已经有n个结点了。 修修非常擅长数数,他很快就数出了包含每个点的连通点集的数量。 澜澜也想知道答案,但他不会数数,于是他把问题交给了你。 输入描述: 第一行一个整数n (1≤ n ≤ 106),接下来n-1行每行两个整数ai,bi表示一条边 ...

LP_Cong 881

华为OD机试真题 新系统 2026-04-26 Python&JS 实现【项目模块依赖构建顺序规划】

某公司正在开发一个大型软件系统,系统包含 N 个模块,每个模块之间存在构建依赖关系。例如,模块 A 可能依赖于模块 B,这意味着必须先构建模块 B,才能构建模块 A。 请根据依赖关系,输出所有可能的模块构建顺序(按照构建顺序排列模块名称),要求:

MISAYAONE的博客 403

牛客国庆集训派对Day3 B Tree(树形dp + 组合计数)

      题意有点绕,其实就是让你求一个点能被多少个点集包含,同时这些点集内的点要相互连通。 首先,简单来说,如果只是计算一个有根树中任意一个点被多少个只包含它以及它的子树的点的点集包含,那么直接普通的树上统计的trick就可以搞定。但是现在问题是,点集的点可以是其子树之外的点。我们注意到,对于根来说,它的答案都满足点集里面的点都在它的子树里面,所以说如果能够把每一个点都当作根来计算...

alpc_qleonardo 907

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

牛客国庆集训派对Day3 B Tree(树形dp + 组合计数)

传送门:https://www.nowcoder.com/acm/contest/203/B 思路及参考:https://blog.youkuaiyun.com/u013534123/article/details/82934820 这篇blog写得非常详细,但是我不会他说的立flag法,就学了其他同学的做法,如果不能做除法,就直接计数。我想了比较久明白的写在注释里啦。 //#pragma GC...

weixin_30501857的博客 193

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

牛客国庆集训派对Day3 B Tree

题目:点击打开链接 题意:略。 分析:树形dp(树上dfs),两遍dfs,一遍求下面(儿子)的贡献,一遍求他父亲节点的贡献,两部分相乘得结果,注意0没有逆元,需要特判。思路参考https://blog.youkuaiyun.com/u013534123/article/details/82934820,写的很详细。 代码: #pragma comment(linker, "/STACK:102400...

常胜将军的博客 271

牛客算法周周练14 C.Tree(树形dp)

牛客算法周周练14 C.Tree题目介绍题目描述输入输出示例题解代码 题目介绍 链接: 传送门. 题目描述 修修去年种下了一棵树,现在它已经有n个结点了。 修修非常擅长数数,他很快就数出了包含每个点的连通点集的数量。 澜澜也想知道答案,但他不会数数,于是他把问题交给了你。 输入 第一行一个整数n (1≤ n ≤ 106),接下来n-1行每行两个整数ai,bi表示一条边 (1≤ ai,bi≤ n)。 输出 输出n行,每行一个非负整数。第i行表示包含第i个点的连通点集的数量对109+7取模的结果。 示例 输入

weixin_43308078的博客 377

牛客国庆集训派对Day3 —— 题解

Scar_Halo 701

牛客国庆集训派对Day3 I-Metropolis (迪杰斯特拉堆优化)

链接:https://www.nowcoder.com/acm/contest/203/I 来源:牛客网   题目描述 魔方国有n座城市,编号为。城市之间通过n-1条无向道路连接,形成一个树形结构。 在若干年之后,其中p座城市发展成了大都会,道路的数量也增加到了m条。 大都会之间经常有贸易往来,因此,对于每座大都会,请你求出它到离它最近的其它大都会的距离。 输入描述: 第一行三个整数n,...

LP_Cong 688

牛客国庆集训派对Day5 B 电音之王

题目:点击打开链接 题意:略。 分析:首先用暴力快速乘O(n*logn)t了,取模一个long long范围内的数太耗时了,但是一直不知道怎么优化取模,后来才知道有蒙哥马利算法优化a*b%c,蒙哥马利算法适用于模数为奇数,入门可参考https://blog.youkuaiyun.com/zgzczzw/article/details/52712980,网上没找到实现代码,下面的代码是杜教的,留着当板子用了...

常胜将军的博客 471

ZUFE 1120 trs滑雪(记忆化搜索)

1120: trs滑雪 时间限制: 1 Sec  内存限制: 128 MB 提交: 63  解决: 22 [提交][状态][讨论版] 题目描述         trs喜欢滑雪。他来到了一个滑雪场,这个滑雪场是一个矩形,为了简便,我们用r行c列的矩阵来表示每块地形。为了得到更快的速度,滑行的路线必须向下倾斜。         例如样例中的那个矩形,可以从某个点滑向上下左右四个相邻的

Mr_Treeeee的博客 672

AtCoder Beginner Contest 082 - D - FT Robot (set||DP)

D - FT Robot Time limit : 2sec / Memory limit : 512MB Score : 500 points Problem Statement A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in th

Mr_Treeeee的博客 642

Codeforces Round #513 - E. Sergey and Subway (树形DP)

http://codeforces.com/contest/1060/problem/E 题意: 问你一棵树上的所有点与点之间的距离。 不过可以2步当成1步走。(跳着走)(即如果两个点隔了一个点,就连一条边) POINT: 首先,如果距离为偶数,直接除2, 如果距离为奇数,除2+1。   算出所有点与点之间的距离(不跳的真实距离)。树形DP解决。 可以算每条边被走了几次,边(u,...

Mr_Treeeee的博客 519

AtCoder Regular Contest 097 - E - Sorted and Sorted (逆序对)

点击打开链接题意:给你黑白两种1-n编号的球。让你交换相邻的球,让黑i在黑i+1的上面。百i在白i+1的上面。POINT:dp[x][y]代表排好了白1-x和黑1-y 编号的球。dp[x][y]从dp[x-1][y]或dp[x][y-1]推出来。用树状数组算出逆序对。#include&lt;iostream&gt; #include&lt;stdio.h&gt; #include&lt;algor...

Mr_Treeeee的博客 497

HDU 1231 最大连续子序列 (DP)

最大连续子序列 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 32448    Accepted Submission(s): 14552 Problem Description 给定K个整数的序列{ N1, N

Mr_Treeeee的博客 483

FZU 2129 子序列个数(计数DP)

Problem 2129 子序列个数 Accept: 282    Submit: 920 Time Limit: 2000 mSec    Memory Limit : 32768 KB  Problem Description 子序列的定义:对于一个序列a=a[1],a[2],......a[n]。则非空序列a'=a[p1],a[p2]......a[pm]为a的一个子

Mr_Treeeee的博客 480
上一篇: EOJ Monthly 2018.10 - C 痛苦的 01 矩阵 (数学推导)
下一篇: 牛客国庆集训派对Day3 - I Metropolis (最短路)
Mr_Treeeee
博客等级 码龄10年 38粉丝 551原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值