diff --git a/README.md b/README.md index 41594eca786e52a5f8089c95d4e76d35b773a96c..8521ea025eda17078c9c1de7aa10b4f9124967eb 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ git clone --depth 1 https://github.com/labuladong/fucking-algorithm.git [build2645](https://github.com/build2645), [CarrieOn](https://github.com/CarrieOn), [Dong Wang](https://github.com/Coder2Programmer), +[ExcaliburEX](https://github.com/ExcaliburEX), [floatLig](https://github.com/floatLig), [Fulin Li](https://fulinli.github.io/), [Funnyyanne](https://github.com/Funnyyanne), @@ -143,6 +144,7 @@ git clone --depth 1 https://github.com/labuladong/fucking-algorithm.git [Kevin](https://github.com/Kevin-free), [Lrc123](https://github.com/Lrc123), [lriy](https://github.com/lriy), +[MasonShu](https://greenwichmt.github.io/), [Master-cai](https://github.com/Master-cai), [miaoxiaozui2017](https://github.com/miaoxiaozui2017), [natsunoyoru97](https://github.com/natsunoyoru97), @@ -165,6 +167,7 @@ git clone --depth 1 https://github.com/labuladong/fucking-algorithm.git [wsyzxxxx](https://github.com/wsyzxxxx), [xiaodp](https://github.com/xiaodp), [youyun](https://github.com/youyun), +[yx-tan](https://github.com/yx-tan), [Zero](https://github.com/Mr2er0), [Ziming](https://github.com/ML-ZimingMeng/LeetCode-Python3) diff --git "a/\351\253\230\351\242\221\351\235\242\350\257\225\347\263\273\345\210\227/\344\270\200\350\241\214\344\273\243\347\240\201\350\247\243\345\206\263\347\232\204\346\231\272\345\212\233\351\242\230.md" "b/\351\253\230\351\242\221\351\235\242\350\257\225\347\263\273\345\210\227/\344\270\200\350\241\214\344\273\243\347\240\201\350\247\243\345\206\263\347\232\204\346\231\272\345\212\233\351\242\230.md" index 7cd5853ec264f9b4c2592615277cd1db38796174..5f70d39d7822652a102e758292ab9d1a947e04ef 100644 --- "a/\351\253\230\351\242\221\351\235\242\350\257\225\347\263\273\345\210\227/\344\270\200\350\241\214\344\273\243\347\240\201\350\247\243\345\206\263\347\232\204\346\231\272\345\212\233\351\242\230.md" +++ "b/\351\253\230\351\242\221\351\235\242\350\257\225\347\263\273\345\210\227/\344\270\200\350\241\214\344\273\243\347\240\201\350\247\243\345\206\263\347\232\204\346\231\272\345\212\233\351\242\230.md" @@ -49,7 +49,7 @@ bool canWinNim(int n) { 最后,你的对手只能拿 1 了。 -这样下来,你总共拥有 $2 + 9 = 11$ 颗石头,对手有 $5 + 1 = 6$ 颗石头,你是可以赢的,所以算法应该返回 true。 +这样下来,你总共拥有 `2 + 9 = 11` 颗石头,对手有 `5 + 1 = 6` 颗石头,你是可以赢的,所以算法应该返回 true。 你看到了,并不是简单的挑数字大的选,为什么第一次选择 2 而不是 5 呢?因为 5 后面是 9,你要是贪图一时的利益,就把 9 这堆石头暴露给对手了,那你就要输了。 @@ -101,15 +101,15 @@ int bulbSwitch(int n) { 我们假设只有 6 盏灯,而且我们只看第 6 盏灯。需要进行 6 轮操作对吧,请问对于第 6 盏灯,会被按下几次开关呢?这不难得出,第 1 轮会被按,第 2 轮,第 3 轮,第 6 轮都会被按。 -为什么第 1、2、3、6 轮会被按呢?因为 $6=1\times6=2\times3$。一般情况下,因子都是成对出现的,也就是说开关被按的次数一般是偶数次。但是有特殊情况,比如说总共有 16 盏灯,那么第 16 盏灯会被按几次? +为什么第 1、2、3、6 轮会被按呢?因为 `6=1x6=2x3`。一般情况下,因子都是成对出现的,也就是说开关被按的次数一般是偶数次。但是有特殊情况,比如说总共有 16 盏灯,那么第 16 盏灯会被按几次? -$16=1\times16=2\times8=4\times4$ +`16=1x16=2x8=4x4` 其中因子 4 重复出现,所以第 16 盏灯会被按 5 次,奇数次。现在你应该理解这个问题为什么和平方根有关了吧? 不过,我们不是要算最后有几盏灯亮着吗,这样直接平方根一下是啥意思呢?稍微思考一下就能理解了。 -就假设现在总共有 16 盏灯,我们求 16 的平方根,等于 4,这就说明最后会有 4 盏灯亮着,它们分别是第 $1\times1=1$ 盏、第 $2\times2=4$ 盏、第 $3\times3=9$ 盏和第 $4\times4=16$ 盏。 +就假设现在总共有 16 盏灯,我们求 16 的平方根,等于 4,这就说明最后会有 4 盏灯亮着,它们分别是第 `1x1=1` 盏、第 `2x2=4` 盏、第 `3x3=9` 盏和第 `4x4=16` 盏。 就算有的 n 平方根结果是小数,强转成 int 型,也相当于一个最大整数上界,比这个上界小的所有整数,平方后的索引都是最后亮着的灯的索引。所以说我们直接把平方根转成整数,就是这个问题的答案。