Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
让他很烦人
Fucking Algorithm
提交
af6787e6
F
Fucking Algorithm
项目概览
让他很烦人
/
Fucking Algorithm
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Fucking Algorithm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
af6787e6
编写于
3月 15, 2021
作者:
B
BruceCat
提交者:
GitHub
3月 15, 2021
浏览文件
操作
浏览文件
下载
差异文件
【292/877/319 一行代码解决的智力题】【Python3】
【292/877/319 一行代码解决的智力题】【Python3】
上级
d30b8dcb
c60cb17e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
2 deletion
+55
-2
高频面试系列/一行代码解决的智力题.md
高频面试系列/一行代码解决的智力题.md
+55
-2
未找到文件。
高频面试系列/一行代码解决的智力题.md
浏览文件 @
af6787e6
...
...
@@ -149,4 +149,58 @@ int bulbSwitch(int n) {
<img
src=
"../pictures/qrcode.jpg"
width=
200
>
</p>
======其他语言代码======
\ No newline at end of file
======其他语言代码======
由
[
JodyZ0203
](
https://github.com/JodyZ0203
)
提供 292. Nim 游戏 Python3 解法代码:
```
Python
class Solution:
def canWinNim(self, n: int) -> bool:
# 如果除于是0,说明是4的倍数,所以必输
# 否则不是除于不等于0,说明不是4的倍数,说明必胜
return n % 4 != 0
```
由
[
JodyZ0203
](
https://github.com/JodyZ0203
)
提供 877. 石子游戏 Python3 解法代码:
```
Python
class Solution:
def stoneGame(self, piles: List[int]) -> bool:
# 双方都很聪明的前提下, 先手必胜无疑
# 先手可以提前观察偶数堆还是基数的石头总数更多
return True
```
由
[
JodyZ0203
](
https://github.com/JodyZ0203
)
提供 877. 石子游戏 C++ 解法代码:
```
cpp
class
Solution
{
public:
bool
stoneGame
(
vector
<
int
>&
piles
)
{
// 双方都很聪明的前提下, 先手必胜无疑
return
true
;
}
};
```
由
[
JodyZ0203
](
https://github.com/JodyZ0203
)
提供 319. 灯泡开关 Python3 解法代码:
```
Python
class Solution:
def bulbSwitch(self, n: int) -> int:
# 平方根电灯个数之后向下取整即可
return floor(sqrt (n))
```
由
[
JodyZ0203
](
https://github.com/JodyZ0203
)
提供 319. 灯泡开关 C++ 解法代码:
```
cpp
class
Solution
{
public:
int
bulbSwitch
(
int
n
)
{
// 平方根电灯个数之后向下取整即可
return
floor
(
sqrt
(
n
));
}
};
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录