0%

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/***
**************************************************************
* *
* .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-. *
* | ______ | *
* | .-" "-. | *
* | / \ | *
* | _ | | _ | *
* | ( \ |, .-. .-. ,| / ) | *
* | > "=._ | )(__/ \__)( | _.=" < | *
* | (_/"=._"=._ |/ /\ \| _.="_.="\_) | *
* | "=._"(_ ^^ _)"_.=" | *
* | "=\__|IIIIII|__/=" | *
* | _.="| \IIIIII/ |"=._ | *
* | _ _.="_.="\ /"=._"=._ _ | *
* | ( \_.="_.=" `--------` "=._"=._/ ) | *
* | > _.=" "=._ < | *
* | (_/ \_) | *
* | | *
* '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=' *
* *
* 栈 *
**************************************************************
*/
Read more »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/***
**************************************************************
* *
* .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-. *
* | ______ | *
* | .-" "-. | *
* | / \ | *
* | _ | | _ | *
* | ( \ |, .-. .-. ,| / ) | *
* | > "=._ | )(__/ \__)( | _.=" < | *
* | (_/"=._"=._ |/ /\ \| _.="_.="\_) | *
* | "=._"(_ ^^ _)"_.=" | *
* | "=\__|IIIIII|__/=" | *
* | _.="| \IIIIII/ |"=._ | *
* | _ _.="_.="\ /"=._"=._ _ | *
* | ( \_.="_.=" `--------` "=._"=._/ ) | *
* | > _.=" "=._ < | *
* | (_/ \_) | *
* | | *
* '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=' *
* *
* 单链表 循环链表 双向链表 循环双向链表 *
**************************************************************
*/
Read more »

Radix Sort is an extension of Bucket Sort, its basic idea is to cut integers into different numbers by digits, and then compare them accroding to each digit.

TC: O(n)

1
2
3
4
5
6
7
8
9
10
11
Data        Ones        Tens    Hundreds
----------------------------------------
053 542 003 003
542 053 014 014
003 003 214 053
063 063 616 063
014 ==> 014 ==> 542 ==> 154
214 214 748 214
154 154 053 542
748 616 154 616
616 748 063 748
Read more »

马飞,使用VIM时是否有这样的烦恼:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#                    _ooOoo_
# o8888888o
# 88" . "88
# (| -_- |)
# O\ = /O
# ____/`---'\____
# . ' \\| |// `.
# / \\||| : |||// \
# / _||||| -:- |||||- \
# | | \\\ - /// | |
# | \_| ''\---/'' | |
# \ .-\__ `-` ___/-. /
# ___`. .' /--.--\ `. . __
# ."" '< `.___\_<|>_/___.' >'"".
# | | : `- \`.;`\ _ /`;.`/ - ` : | |
# \ \ `-. \_ __\ /__ _/ .-` / /
# ======`-.____`-.___\_____/___.-`____.-'======
# `=---='
#
# .............................................
# 佛祖保佑 永无BUG

然后,当你愉快的按下回车时,你会发现:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#                    _ooOoo_
# o8888888o
# 88" . "88
# (| -_- |)
# O\ = /O
# ____/`---'\____
# . ' \\| |// `.
# / \\||| : |||// \
# / _||||| -:- |||||- \
# | | \\\ - /// | |
# | \_| ''\---/'' | |
# \ .-\__ `-` ___/-. /
# ___`. .' /--.--\ `. . __
# ."" '< `.___\_<|>_/___.' >'"".
# | | : `- \`.;`\ _ /`;.`/ - ` : | |
# \ \ `-. \_ __\ /__ _/ .-` / /
# ======`-.____`-.___\_____/___.-`____.-'======
# `=---='
#
# .............................................
# 佛祖保佑 永无BUG
#

VIM竟然会自动注释补全,wdnmd.

查阅无数资料,功夫不负有心人,终于: https://vi.stackexchange.com/questions/1983/how-can-i-get-vim-to-stop-putting-comments-in-front-of-new-lines/1985

学成归来,总之就是:

VIM的自动注释补全归formatoptions管,有三个值:

1
2
3
4
5
6
7
8
r       Automatically insert the current comment leader after hitting
<Enter> in Insert mode.

c Auto-wrap comments using textwidth, inserting the current comment
leader automatically.

o Automatically insert the current comment leader after hitting 'o' or
'O' in Normal mode.

取消VIM的自动只是补全也很简单,只需要将下面的一条命令写入.vimrc文件中:

1
2
3
4
5
au FileType * set fo-=c fo-=r fo-=o

或者

set fo=

但是,上面的两条命令不管用,原因是在启动过程中,vim首先加载.vimrc文件,然后加载各种插件,坑就坑在有些插件设置了formatoptions的值,也就是说,你的更改被插件覆盖了,为了避开这个问题,将命令改为下面的样子写入.vimrc文件中即可:

1
au BufEnter * set fo-=c fo-=r fo-=o

Author: James L. Massey
publication: IEEE, 1994

Abstract: It is shown that the average number of successive guesses, \(E[G]\), required an optimum strategy until one correrctly guesses the value of a discrete random \(X\), is underbounded by the entropy \(H(X)\) in the manner \(E[G] \ge (1/4)^{H(X)} + 1\) provided that \(H(X) \ge 2\)bits. This bound is tight within a factor of \((4/e)\) when \(X\) is eometrically distributed. It is further shown that \(E(G)\) may be arbitrarily large when \(H(X)\) is an arbitrarily small positive number so that there is no interesting upper bound on \(E(G)\) in terms of \(H(X)\).

连续猜测平均值的上下限与熵的关系。

符号 符号说明
\(X\) 离散随机值
\(G\) 成功猜测X的最小次数
\(E[G], A\) G的期望
\(p\) 每次猜测的概率
\(H(X)\) X的熵
\(P_{geom}\) 几何分布
\(h(P_{geom})\) 几何分布的熵

下限的确定

对于每次猜测\(X\)的概率\(p=(p_1,p_2,p_3,...)\)满足\(p_1 > p_2 > p_3 > ...\),此时我们 可以称其为单调分布。\(G\)的期望\(E[G] = \sum i \cdot p_i\), 期望的范围是$[1,) $.

期望的范围是\([1, \infty)\)
因为概率和\(p_1+p_2+p_3+... = 1\),而i从1开始,因此\(\sum i \cdot p_i > 1\)

根据熵的公式\(h(p) = -\sum p_i \cdot log(p_i)\) 和参考文献[1]给出的公式\(p_i = (1/(A-1))(1-1/A)^i\) 可以推出: \[ h(P_{geom}) = log(A-1) + log(1-1/A)^{-A} \]

推导过程
\[ h(P_{geom}) = -\sum (\frac{1}{A-1})(1-\frac{1}{A})^i \cdot log(\frac{1}{A-1}) (1-\frac{1}{A})^i \\ = \frac{1}{A-1} \sum i(1-\frac{1}{A})^i \cdot log(A-1)(1-\frac{1}{A})\\ = \frac{1}{A-1} log(A-1)(1-\frac{1}{A}) \cdot \sum i(1-\frac{1}{A})^i\\ = \frac{1}{A-1} log(A-1)(1-\frac{1}{A}) \cdot \frac{1-\frac{1}{A}}{(\frac{1}{A}) ^2}\\ = A log(A-1)(1-\frac{1}{A})\\ = log(A-1) + log(1-\frac{1}{A})^-A \]

随着A的增大,上述等式的右边第二项趋近于\(log(e)\). 并且当\(A=2\)也即\(h(P_{geom}) = 2\)时,上述等式右边第二项\(log(1-\frac{1}{A})^-A = 2\),换句话讲,当\(h(P_{geom}) \ge 2\)时, \[ A \ge (1/4) \cdot 2^{H(X)} +1 \]

推导过程
\[ h(p) \le log(A-1) +2 \\ log(A-1) \ge h(p) -2 \\ A-1 \ge 2^{h(p)-2} = (1/4) \cdot 2^{h(p)} \\ A \ge (1/4) \cdot 2^{h(p)} +1 \]

又因为\(h(P_{geom}) = log(A-1) + log(1-1/A)^{-A}\)右边第二项最小值为\(log(e)\),因此: \[ h(P_{geom}) \ge log(A-1) + log(e) \] 即: \[ A \le (1/e) \cdot 2^{h(P_{geom})} +1 \]

There are many ways to implement network proxy, such as Socket5, VMess protocal, and the software that uses these protocols includes ShadowSocket, ShadowSocketR, V2ray, etc. Due to national policy reasons, these software cannot be updated and iterated smoothly, and always disappear in the period of prosperity. I have used the above-mentioned proxy software, but finally chose to give up because it cannot update the existing bugs.

Recently, I discovered a brand-new mature network proxy software: ClashX, which supports ss, vmess, socks5 and trojan protocols. ClashX specifically refers to running on MacOS system.

Read more »

Citation

We will continue to introduce the second camp of symmetric ciphers: block ciphers. Two major events occurred in the computer field in the 1970s, which marked the entry of cryptography into the category of modern cryptography. One is today's main content DES(Data Encryption Standard), and the other is the birth of public key cryptography.

Read more »