置顶
以 2022-10-23 纪念本人入坑洛谷,开始 OIer 生涯。
注:本网页由 Github Pages 托管,国内访问速度极慢,国内用户可前往 CDN 加速网站 ,内容完全一样。
大家好!
我是 George222,你也可以叫我 222。
作...
置顶
update on 2024/9/12
前言配置环境
语法输入输出
循环
变量与数组
if 判断语句(分支结构)
函数
结构体
基本算法枚举与模拟
递归
递推
DP
Floyd(最短路初步)
进阶算法倍增 and RMQ an...
置顶
配置网站框架评论功能redefine自定义前置准备
安装 node js
安装 git
安装 Hexo
创建 Github 仓库。
node js:1https://nodejs.org/zh-cn
git:注:git 安装时一直继续就好,但是...
思路考虑贪心算法。
对于一个平均数,要想使平均数大就要取尽可能大的数,否则一定会拉低平均值。
而且取任何比 小的数一定会拉低平均值,所以我们选择只取前 大的值。
继续解决方案数部分。
对于方案数的增加,只有多个与 相同的值才能起效果。
为...
LCA,最近公共祖先问题。
给定一颗有根树,若节点 k 既是节点 x 的祖先,又是节点 y 的祖先,则称 k 是 的公共祖先。在 的所有公共祖先中,深度最大的称为最近公共祖先,记作 。
即为节点 和节点 的第一个中途交汇点。
因为讲解倍增...
什么是倍增?倍增,从字面及数学的角度就是 ”成倍增长“ 的意思。这能使线性问题转化为数级处理,优化时间复杂度。
不是人话是不是?听不懂是不是? 看这里。这是指我们在进行递推时,如果状态空间很大,通常的线性递推无法满足时间与空间复杂度的要求,那么我们可...
DP 概述DP(Dynamic programming,全称动态规划),是一种基于分治,将原问题分解为简单子问题求解复杂问题的方法。
动态规划的耗时往往远少于朴素(爆搜)解法。
动态规划 and 递归之前说过,动态规划也是分治思路,而递归更是传统的分...
算法用途:Floyd 算法是用于解决两点间最短路径的一种算法,可以处理有向图或负权的最短路问题。
该算法时间复杂度为 ,空间复杂度为 。
算法原理Floyd 算法基于动态规划实现。
Floyd 算法一直在解决一个问题,寻找 的最短路径 (废话)。...
P11000,纪念这个特别的数字,来水一篇。
用 没有任何特殊情况的方法数:。
排除没有 和 的方法。
加上 和 混一起的方法数。
答案为:。
附:计算过程
我们现在考虑递推。
现在的问题是,如何从前几个数据推导出下一个数据。
我们现在先推导 。
设 。
到 的方法就是到能一步到 的台阶的方法总和,所以我们可以推导出:
。
即为:。
代码如下:
12345678910111213141516#inc...