计算乘法很简单,但是如果数据规模过大就会超时了,所以就有了快速幂这个算法。 原理: 如果b是奇数,就有ab=a * a(b-1) 如果b是偶数,就有ab=a(b/2) *a^(b/2) 举个例子 2^4 24 = 22 * 22 22 = 21 * 21 21 = 2 = 20 2^0 = 1 (例 ...
分类:
其他好文 时间:
2020-06-06 12:56:06
阅读次数:
55
Domain events: design and implementation https://martinfowler.com/eaaDev/DomainEvent.html Implement value objects ...
分类:
其他好文 时间:
2020-06-05 15:08:52
阅读次数:
60
用到了pygame,主要是这个方便演示: 框架用了pygame+thinker,感觉上是不相容的,因为用了pygame,底层它实现,你怎么可能再用thinker呢,它也有自己的一套,结果国外高手把这两个整合在一起了,有好的方面,一个表示图形切换简单,一个有按钮。 八皇后问题用了全排列:8的8次方中排 ...
分类:
编程语言 时间:
2020-06-04 21:29:11
阅读次数:
86
1、问题如下,在新建的python虚拟环境中执行 activate 命令时报错; 2、解决方式; 1)、在powershell中执行 “set-ExecutionPolicy”; 2)、在提示中输入“RemoteSigned” 3)、在提示中输入“Y” 3、再次执行“activate”时,成功了,问 ...
package LeetCode_50 /** * 50. Pow(x, n) * https://leetcode.com/problems/powx-n/description/ * * Implement pow(x, n), which calculates x raised to the ...
分类:
其他好文 时间:
2020-06-04 01:10:44
阅读次数:
68
Math.abs、Math.max、Math.min、Math.floor、Math.ceil、Math.round、Math.pow、Math.sqrt、Math.random、Math.trunc、Math.sign ...
分类:
其他好文 时间:
2020-06-03 20:23:27
阅读次数:
104
本节将开始介绍cartographer前端点云与地图匹配获取当前位姿的算法。上节末尾我们提到ScanMatch函数,源码如下: std::unique_ptr<transform::Rigid2d> LocalTrajectoryBuilder2D::ScanMatch( const common: ...
分类:
其他好文 时间:
2020-06-02 11:38:15
阅读次数:
88
递归法 思路: 在计算一个数x的n次幂时xn,我们可以先递归计算出x的n//2次幂y=xn//2,然后根据递归计算的结果,如果n是偶数,则结果为xn=y2,否则xn=y2*x。 例如: X77 = (X38)2 * X = ((X19)2)2 * X = (((X9)2 *X)2)2 * X = ( ...
分类:
其他好文 时间:
2020-06-01 13:35:09
阅读次数:
64
The Happy Prince and Other Tales 给定长度为 \(n+1\) 的数列 \(\langle a_i\rangle_{i=0}^n\),请对于 \(\forall m\in[0,n]\) 输出 \(f_m(n)\bmod 998244353\), \[ f_m(n)=\s ...
分类:
移动开发 时间:
2020-06-01 12:04:31
阅读次数:
70
四、子序列 ? 1.最长子序列 ? 给定一个字符串‘s’和一个整数k,找到其他字符串‘t’,使得‘t’是给定字 符串‘s’的最大子序列,同时‘t’的每个字符在字符串s中必须至少出现k次。 ? Input: s = "baaabaacba“, k = 3 ? Output : baaabaaba im ...
分类:
其他好文 时间:
2020-05-30 12:48:11
阅读次数:
72