Skip to content

Commit 6f45fbc

Browse files
committed
add translator ExcaliburEX MasonShu yx-tan
1 parent 51d316f commit 6f45fbc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ git clone --depth 1 https://github.com/labuladong/fucking-algorithm.git
132132
[build2645](https://github.com/build2645),
133133
[CarrieOn](https://github.com/CarrieOn),
134134
[Dong Wang](https://github.com/Coder2Programmer),
135+
[ExcaliburEX](https://github.com/ExcaliburEX),
135136
[floatLig](https://github.com/floatLig),
136137
[Fulin Li](https://fulinli.github.io/),
137138
[Funnyyanne](https://github.com/Funnyyanne),
@@ -143,6 +144,7 @@ git clone --depth 1 https://github.com/labuladong/fucking-algorithm.git
143144
[Kevin](https://github.com/Kevin-free),
144145
[Lrc123](https://github.com/Lrc123),
145146
[lriy](https://github.com/lriy),
147+
[MasonShu](https://greenwichmt.github.io/),
146148
[Master-cai](https://github.com/Master-cai),
147149
[miaoxiaozui2017](https://github.com/miaoxiaozui2017),
148150
[natsunoyoru97](https://github.com/natsunoyoru97),
@@ -165,6 +167,7 @@ git clone --depth 1 https://github.com/labuladong/fucking-algorithm.git
165167
[wsyzxxxx](https://github.com/wsyzxxxx),
166168
[xiaodp](https://github.com/xiaodp),
167169
[youyun](https://github.com/youyun),
170+
[yx-tan](https://github.com/yx-tan),
168171
[Zero](https://github.com/Mr2er0),
169172
[Ziming](https://github.com/ML-ZimingMeng/LeetCode-Python3)
170173

高频面试系列/一行代码解决的智力题.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool canWinNim(int n) {
4949
5050
最后,你的对手只能拿 1 了。
5151
52-
这样下来,你总共拥有 $2 + 9 = 11$ 颗石头,对手有 $5 + 1 = 6$ 颗石头,你是可以赢的,所以算法应该返回 true。
52+
这样下来,你总共拥有 `2 + 9 = 11` 颗石头,对手有 `5 + 1 = 6` 颗石头,你是可以赢的,所以算法应该返回 true。
5353
5454
你看到了,并不是简单的挑数字大的选,为什么第一次选择 2 而不是 5 呢?因为 5 后面是 9,你要是贪图一时的利益,就把 9 这堆石头暴露给对手了,那你就要输了。
5555
@@ -101,15 +101,15 @@ int bulbSwitch(int n) {
101101

102102
我们假设只有 6 盏灯,而且我们只看第 6 盏灯。需要进行 6 轮操作对吧,请问对于第 6 盏灯,会被按下几次开关呢?这不难得出,第 1 轮会被按,第 2 轮,第 3 轮,第 6 轮都会被按。
103103

104-
为什么第 1、2、3、6 轮会被按呢?因为 $6=1\times6=2\times3$。一般情况下,因子都是成对出现的,也就是说开关被按的次数一般是偶数次。但是有特殊情况,比如说总共有 16 盏灯,那么第 16 盏灯会被按几次?
104+
为什么第 1、2、3、6 轮会被按呢?因为 `6=1x6=2x3`。一般情况下,因子都是成对出现的,也就是说开关被按的次数一般是偶数次。但是有特殊情况,比如说总共有 16 盏灯,那么第 16 盏灯会被按几次?
105105

106-
$16=1\times16=2\times8=4\times4$
106+
`16=1x16=2x8=4x4`
107107

108108
其中因子 4 重复出现,所以第 16 盏灯会被按 5 次,奇数次。现在你应该理解这个问题为什么和平方根有关了吧?
109109

110110
不过,我们不是要算最后有几盏灯亮着吗,这样直接平方根一下是啥意思呢?稍微思考一下就能理解了。
111111

112-
就假设现在总共有 16 盏灯,我们求 16 的平方根,等于 4,这就说明最后会有 4 盏灯亮着,它们分别是第 $1\times1=1$ 盏、第 $2\times2=4$ 盏、第 $3\times3=9$ 盏和第 $4\times4=16$ 盏。
112+
就假设现在总共有 16 盏灯,我们求 16 的平方根,等于 4,这就说明最后会有 4 盏灯亮着,它们分别是第 `1x1=1` 盏、第 `2x2=4` 盏、第 `3x3=9` 盏和第 `4x4=16` 盏。
113113

114114
就算有的 n 平方根结果是小数,强转成 int 型,也相当于一个最大整数上界,比这个上界小的所有整数,平方后的索引都是最后亮着的灯的索引。所以说我们直接把平方根转成整数,就是这个问题的答案。
115115

0 commit comments

Comments
 (0)