Codeforces Round #695 (Div. 2)D. Sum of Paths【计数题】

Codeforces 870E:计数问题 题意:给出N个二维点,坐标都是整数,每个点可以不画线,也可以画一条竖直的线,也可以画一条水平的线,但是最多只能画一条线。 求图案方案数。 题解: 假设两个点他们相互独立,那么答案就是组合一下,可以分别来算。那么思路就是:把相互之间冲突的点放到一个联通快中,然后每个联通快单独计算,再乘起来就行了。 冲突定义为:两个点要么横坐标相同,要么纵坐标相同,要么同时和第三个点冲突。(也就是说一个联 阅读详情

题目链接___

复健复健!考完试了,我的力量都回到我这里来吧!
题意:
给定n个长度小格子,每步可以走到-1或+1下标,不能越界。
走k步产生一个序列: c 0 , c 1 , c 2 … … c k c_0,c_1,c_2……c_k c0​,c1​,c2​……ck​对应 A c 0 + A c 1 + A c 2 . . . . . A_{c0}+A_{c1}+A_{c2}..... Ac0​+Ac1​+Ac2​.....
求所有这样序列总和。即:路径下标权值和为路径权值,求所有路径权值和

本题难以从逐个递推角度求解。我设了一些函数都难以处理这个状态的转移。最后设了一个: f ( i , j ) f( i, j ) f(i,j)表示:从下标i出发走j步的不同路径方案数;
然后发现一个问题:起点终点是完全可逆的,也就是说这个函数可以理解为:从不同地方走到下标i位置的不同路径方案数。于是乎:
i被踩了多少次? 等于任何地方路过i的次数设g 表示从不同地方走到下标i的不同路径方案数,有f(i,g)方案数,剩下的k-g步,如何消耗,仍采用f(i,k-g),于是:
c n t i = ∑ j = 0 k f ( i , j ) ∗ f ( i , k − j ) cnt_i = \sum_{j=0}^{k}f(i,j)*f(i,k-j) cnti​=∑j=0k​f(i,j)∗f(i,k−j)
表示下标i 访问次数。整体时间复杂度为nk;

代码:___________________

Apache Doris IP变更问题详解 阅读详情

相关推荐

使用kmplot在线进行生存分析

欢迎关注”生信修炼手册”!kmplot是一个生存分析的在线工具,最初是设计用来对肝癌中的miRNA进行生存分析,对应的文章发表在scientific reports上,链接如下https...

庐州月光的博客 1万+

【Usaco2010 Open Gold-1】奶牛的跳格子游戏

题目 Description 奶牛们正在回味童年,玩一个类似跳格子的游戏,在这个游戏里,奶牛们在草地上画了一行N个格子,(3 <=N <= 250,000),编号为1..N。就像任何一个好游戏一样,这样的跳格子游戏也有奖励!第i个格子标有一个数字V_i(-2,000,000,000 <=V_i <= 2,000,000,000)表示这个格子的钱。奶牛们想看看最后谁能得到最多的钱。规则很简单: * 每个奶牛从0号格子出发。(0号格子在1号之前,那里没钱) * 她向N号格子进行一系列

weixin_43823476的博客 436

深入解析ChangeFormer:基于Transformer的孪生网络在遥感变化检测中的创新应用

本文深入解析了ChangeFormer这一基于Transformer的孪生网络在遥感变化检测中的创新应用。通过分层Transformer编码器、特征差异计算模块和轻量级MLP解码器的设计,ChangeFormer在LEVIR-CD数据集上取得了90.4%的F1分数,显著优于传统卷积网络。文章还详细探讨了工程化实现、训练调参和模型部署的优化策略,为遥感变化检测领域提供了新的技术范式。

weixin_29051811的博客 731

CF698Div2-D. Sum of Paths-dp,组合数学

题目大意: 给你一个一维的方格[1,n][1,n][1,n]。一个机器人每一步只能移动到相邻的格子上.现在问你所有长度为kkk的合法路径中x1→x2→...→xkx_1\rightarrow x_2\rightarrow ...\rightarrow x_kx1​→x2​→...→xk​,总共出现了多少次i,∀ i∈[1,n]i,\forall \ i\in [1,n]i,∀ i∈[1,n]. 题目思路: 计算方法:计算所有长度为kkk的合法位置中,每一个位置对iii的贡献(iii出现

qq_35577488的博客 309

工业音频故障检测:从CNN到Transformer的技术演进

音频信号处理是工业设备预测性维护的核心技术之一,通过分析设备运行时产生的声波特征实现故障预警。传统方法依赖梅尔频率倒谱系数(MFCC)等手工特征,而深度学习技术尤其是Transformer架构,通过自注意力机制突破了CNN在跨频段特征提取上的局限。Audio Spectrogram Transformer(AST)等先进模型在工业场景中展现出91.2%的高召回率,显著优于传统方案。这种非接触式监测技术结合边缘计算优化,已成功应用于石油化工、电力能源等领域,实现提前72小时预测轴承故障,单项目可避免数百万元的

weixin_30467861的博客 326

ESP32搭配FT6236触摸屏:从芯片手册到完整I2C驱动代码的保姆级解析

本文详细解析了ESP32搭配FT6236触摸屏的I2C驱动开发过程,从芯片手册解读到完整代码实现。通过硬件架构分析、寄存器配置、I2C通信封装及触摸数据处理等步骤,提供了一套完整的驱动解决方案,帮助开发者快速掌握ESP32与触摸屏的交互技术。

weixin_29174385的博客 291

Codeforces 15E Trangles (计数)

#include #include #include #include #include #include #include #include #include using namespace std; #define inf 0x3f3f3f3f #define N 1020 #define LL long long #define

yamiedie_ 596

PTPX功耗分析实战——从脚本配置到报告解读

本文详细介绍了PTPX功耗分析的全流程,从脚本配置到报告解读,帮助工程师快速掌握芯片设计中的功耗估算技术。文章涵盖了环境搭建、波形文件处理、功耗报告解析等关键环节,并提供了实战经验和优化建议,特别适合需要提升PTPX功耗分析效率的开发者。

weixin_29248313的博客 279

Codeforces 439E Devu and Birthday Celebration(计数问题)

题目链接:Codeforces 439E Devu and Birthday Celebration 题目大意:给出q,表示询问的次数,每次询问有n和f,问有多少种分类方法,将n分成f份,并且这f份的最大共约数为1. 解题思路:如果不考虑说最大共约数为1的话,那么问题很简单,就是f个数的和为n的种数C(f−1n−1).所以我们就尽量将问题转化成说f数的和为s的子问题。用容斥原理,总的可

不慌不忙、不急不躁 1514

使用 Visual Studio Code 搭建 SAP UI5 本地开发环境

工欲善其事,必先利其器。时至今日,SAP 提供了非常多的 SAP UI5 开发工具,既包含本地搭建的,也包含浏览器里远端使用的工具,比如 WebIDE 和 Business Application Studio. 我们访问下面这个链接,就能找到所有这些工具的安装或者配置步骤: https://tools.hana.ondemand.com/#sapui5 如果想选择本地开发,SAP 推荐的工具是 Visual Studio Code,也就是本文要介绍的内容。 也可以下载 WebIDE 的本地安装包,将其安

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1万+

2026年1至9月武汉市房地产价格深度分析报告

本报告基于2026年1月至9月武汉市实际成交案例,从成交价格、区域分布、户型结构、价格走势等维度进行深度分析。数据来源包括武汉市住房保障和房屋管理局备案数据、主要中介机构成交记录及典型楼盘网签案例,覆盖全市15个行政区及主要功能板块。

王国平的博客 327

Codeforces Round #695 (Div. 2)A-D题解

Codeforces Round #695 (Div. 2)A-D 这一场比赛的题的难度别cf其他的div2的要难多了。可能是自己好久没打,菜了。 所以写一下这篇题解,记录一下自己的思考过程。 A. Wizard of Orz 题目链接:点击此处 这一题难点在在长度为找哪个作为起始点,很明显,n==1n==1n==1的时候,选第一个在第9秒,n==2n==2n==2,选第二个在第8秒,n==3n==3n==3时选第二个在第8秒,后续也一样,之后自己推一下就可以出来。 #include<iostream

qq_48344603的博客 301

2024年全国青少年信息素养大赛复赛真题(算法创意实践挑战赛C++试卷:带解析)

2024年全国青少年信息素养大赛复赛真题(算法创意实践挑战赛C++试卷:带解析)

王老师青少年编程 4785

Codeforces Round #695 (Div. 2)

文章目录Codeforces Round #695 (Div. 2)A. Wizard of OrzB. Hills And ValleysC. Three BagsD. Sum of PathsE. Distinctive Roots in a Tree Codeforces Round #695 (Div. 2) A. Wizard of Orz 题意: 有n个灯,每个灯一开始都是0,每一秒钟每个灯显示的数字会往上一位,但是由于每个灯只能显示单个数位,所以从9增大时得到的是0.在任意时刻,你可以指定唯一

m0_49959202的博客 138

廖雪峰Python教程[完整版]

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

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

Codeforces Round #695 (Div. 2) D. Sum of Paths(dp)

D. Sum of Paths 题意 一共有 nnn 个格子,每个格子都有一个值 aia_iai​。一开始可以在任意一个格子放置一个机器人,机器人精确的走 kkk 步经过 k+1k+1k+1 个格子,走过一个格子产生 aia_iai​ 的贡献,问所有不同的走法产生的总贡献,有 qqq 次询问,每次询问都可以修改一个格子的值。 题解 先预处理出所有走法每个格子会被走的次数总和,然后每次询问 O(1)O(1)O(1) 计算即可。 dp[i][j]dp[i][j]dp[i][j] 表示第 jjj 步走到第 i

bandiaoz的博客 210

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

【Codeforces Round #695 (Div. 2) D】Sum of Paths

题目链接 链接 翻译 可以从数组中任意一个位置开始出发走一条路径,每一步可以往走到相邻的一个格子(左或右)。但是不能超过边界。 问你所有不同的长度为 \(k+1\) 的路径的和是多少。 然后要支持更新操作实时回答这个路径和。 题解 \(n\) 和 \(k\) 都只有 \(5000\),其实是比较容易往 \(DP\) 上面想的。 实时更新的话,只要能够知道最后每个数字在答案中的贡献 \(c...

AWCXV 226

Camera2Demo

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

Codeforces Round #695 (Div. 2) D. Sum of Paths

题目链接 There are nnn cells, numbered 1,2,…,n1,2,\dots, n1,2,…,n from left to right. You have to place a robot at any cell initially. The robot must make exactly kkk moves. In one move, the robot must move one cell to the left or right, provided that it doesn

sky123博客 224

Codeforces Beta Round #17 C. Balance (字符串计数 dp)

C. Balance time limit per test 3 seconds memory limit per test 128 megabytes input standard input output standard output Nick likes strings very much, he likes to rotate

To be what you what to be! 1606

codeforces 的一些数学题

https://codeforces.com/problemset/problem/1129/E 这题就是一个主要的想法是变成有根树,然后自下而上确定点,每次二分未确定父亲的集合找出父亲。 已写。 https://codeforces.com/problemset/problem/1129/D 考虑一个一维dp,\(dp[i]=\sum_j [j<i][f(i,j) \leq k] dp[j...

weixin_30929295的博客 520

codeforces 简单计数问题收集

开个新坑。。 所谓简单计数问题, 就是运用组合数学或者一些计数技巧,去统计某个对象的个数。这些题往往码量不大, 思路灵活。如果这方面的“直觉”很强的话, 解题会很轻松。codeforces 70C - Lucky Tickets容易想到的是, 给定一个区间, 在 nlogn 内求出其 good pairs 的计数。即对 first , 维护 i / rev[i] 的个数。然后枚举 second,加

slowlight93的专栏 1161

CF1467D Sum of Paths dp

题目链接 题意: 给你一个长度为nnn的序列,其中第iii个位置权值为aia_iai​,要有kkk次移动,每次移动向左或向右移动一格,不能出边界(到000或者n+1n+1n+1),对于这样一个连续移动kkk次后得到的长度为k+1k+1k+1的经过位置序列,我们称之为好序列,它的权值是经过的每一个位置的aia_iai​之和,其中多次经过的话要多次累加。现在对于所有起始位置,求所有好序列的权值和,并且有qqq次对序列权值的修改。答案对1e9+71e9+71e9+7取模。 n,k<=5000,q<=2

forever_shi的博客 445

Codeforces上几个非常妙的数据结构题

第一次做线段树优化dp.没想到div.2的D这么难,以后真的要退竞了. 题意 将一串数字分为k个连续区间,使得每一段中出现数字种数的总和最大. 做法 我们先来思考一下裸的dp. 定义dp[i][j]为前i−1i−1i-1个数分割为jjj份的最大值. 因此有代码 dp[i][j]=max(dp[k=1 to i][j-1])+sum(k,n); /*此处的sum(k,n)是k ...

Fuko_Ibuki的博客 1万+

1467D. Sum of Paths(妙用dp的含义)

传送门 话说这个DDD好水… 只要提前预处理每个格子被走过的次数cnt[i]cnt[i]cnt[i]就好了 f[i][j]f[i][j]f[i][j]表示走了iii步后在点jjj的方案数 由于起点任选那么有f[0][i]=1f[0][i]=1f[0][i]=1 转移为f[i][j]=f[i−1][j−1]+f[i−1][j+1]f[i][j]=f[i-1][j-1]+f[i-1][j+1]f[i][j]=f[i−1][j−1]+f[i−1][j+1] 那么现在考虑求cnt[i]cnt[i]cnt[i],就是

jziwjxjd的博客 3253
上一篇: Dsu on tree树上启发式合并经典例题算法代码剖析
下一篇: Educational Codeforces Round 102 C/D题解【构造】和【维护乱搞】
DevourPower
博客等级 码龄7年 52粉丝 78原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值