题目链接:https://www.luogu.com.cn/problem/P3964 思路:可以发现题目中是求切比雪夫距离和最小,可以先把切比雪夫距离转换成曼哈顿距离。比雪夫距离(x,y),转换成曼哈顿距离就变成了( (x+y)/2,(x-y)/2 )。为了避免浮点数,可以先不除2,最后结果再除2 ...
分类:
其他好文 时间:
2020-10-05 22:25:12
阅读次数:
23
ALGS4 Exercise 1.5.15 Problem Binomial trees. Show that the number of nodes at each level in the worst-case trees for weighted quick-union are binomia ...
分类:
编程语言 时间:
2020-10-05 21:48:17
阅读次数:
42
题目链接 题意:给你n和m,令x为前m个素数,一共使用n个的乘积,例如n=3,m=2,则x=2*2*3或x=2*3*3,求所有Φ(x)的和。 思路:用到了欧拉函数的性质,首先对于x为素数,Φ(x)=x-1,然后若n*m=x,则Φ(n)*Φ(n)=Φ(x)。所以我们可以求出前500个素数,然后对其进行 ...
分类:
其他好文 时间:
2020-09-24 20:50:23
阅读次数:
36
Flood Fill 可以在线性时间复杂度内找到某个点所在的连通块 1097.池塘计数 链接:https://www.acwing.com/problem/content/1099/ #include <iostream> #include <algorithm> #include <cstring ...
分类:
编程语言 时间:
2020-09-24 00:00:51
阅读次数:
38
https://www.luogu.com.cn/problem/P4721 很多题的dp方程写出来后是这种形式 这种东西当然可以cdq分治FFT解决 但实际上做一些推导就可以只利用多项式求逆解决 这个递推式可以这么来看 fn表示 用一些长度为1...n-1的长条 来组成 一个长度为n的长条一共有多 ...
分类:
其他好文 时间:
2020-09-18 03:15:13
阅读次数:
27
题目 题目链接:http://noip.ybtoj.com.cn/problem/20053 思路 将被敬仰的人向敬仰他的人连一条有向边,那么如果存在环显然无解。 否则由于每个点入度最多为 $1$,所以形成了一棵树形结构。 设 \(f[x]\) 表示 \(x\) 子树内排序的方案数。考虑加入一棵子树 ...
分类:
其他好文 时间:
2020-09-18 03:05:10
阅读次数:
43
给定一个二维网格和一个单词,找出该单词是否存在于网格中。 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。同一个单元格内的字母不允许被重复使用。 示例: board = [ ['A','B','C','E'], ['S','F','C','S' ...
分类:
其他好文 时间:
2020-09-18 02:05:24
阅读次数:
30
/** * Calculate the size of the mempool header. * * @param mp * Pointer to the memory pool. * @param cs * Size of the per-lcore cache. */ #define MEMP ...
分类:
其他好文 时间:
2020-09-18 01:52:20
阅读次数:
30
Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k num ...
https://pintia.cn/problem-sets/994805046380707840/problems/994805050277216256 从右向左枚举所有的点 假设枚举到i,考虑让哪个点看到i最优 如上图,当ik的斜率大于等于ij的斜率时,对于i点来说j是不需要的 所以对于每个点要 ...
分类:
其他好文 时间:
2020-09-18 01:07:47
阅读次数:
65