mirror of
https://github.com/labuladong/fucking-algorithm.git
synced 2025-07-06 12:33:00 +08:00
Update 一行代码解决的智力题.md
This commit is contained in:
@ -152,7 +152,8 @@ int bulbSwitch(int n) {
|
||||
======其他语言代码======
|
||||
|
||||
由[JodyZ0203](https://github.com/JodyZ0203)提供 292. Nim 游戏 Python3 解法代码:
|
||||
```Python3
|
||||
|
||||
```Python
|
||||
class Solution:
|
||||
def canWinNim(self, n: int) -> bool:
|
||||
# 如果除于是0,说明是4的倍数,所以必输
|
||||
@ -161,7 +162,8 @@ class Solution:
|
||||
```
|
||||
|
||||
由[JodyZ0203](https://github.com/JodyZ0203)提供 877. 石子游戏 Python3 解法代码:
|
||||
```Python3
|
||||
|
||||
```Python
|
||||
class Solution:
|
||||
def stoneGame(self, piles: List[int]) -> bool:
|
||||
# 双方都很聪明的前提下, 先手必胜无疑
|
||||
@ -170,6 +172,7 @@ class Solution:
|
||||
```
|
||||
|
||||
由[JodyZ0203](https://github.com/JodyZ0203)提供 877. 石子游戏 C++ 解法代码:
|
||||
|
||||
```cpp
|
||||
class Solution {
|
||||
public:
|
||||
@ -182,7 +185,8 @@ public:
|
||||
|
||||
|
||||
由[JodyZ0203](https://github.com/JodyZ0203)提供 319. 灯泡开关 Python3 解法代码:
|
||||
```Python3
|
||||
|
||||
```Python
|
||||
class Solution:
|
||||
def bulbSwitch(self, n: int) -> int:
|
||||
# 平方根电灯个数之后向下取整即可
|
||||
@ -190,6 +194,7 @@ class Solution:
|
||||
```
|
||||
|
||||
由[JodyZ0203](https://github.com/JodyZ0203)提供 319. 灯泡开关 C++ 解法代码:
|
||||
|
||||
```cpp
|
||||
class Solution {
|
||||
public:
|
||||
|
Reference in New Issue
Block a user