Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_algorithm
提交
88724d3b
S
skill_tree_algorithm
项目概览
CSDN 技术社区
/
skill_tree_algorithm
通知
9
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_algorithm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
88724d3b
编写于
10月 29, 2021
作者:
每日一练社区
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update exercises
上级
2eda9185
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
355 addition
and
21 deletion
+355
-21
data/1.算法初阶/1.蓝桥杯/夺冠概率/solution.cpp
data/1.算法初阶/1.蓝桥杯/夺冠概率/solution.cpp
+1
-1
data/1.算法初阶/1.蓝桥杯/方格分割/solution.cpp
data/1.算法初阶/1.蓝桥杯/方格分割/solution.cpp
+13
-13
data/1.算法初阶/1.蓝桥杯/方格分割/solution.md
data/1.算法初阶/1.蓝桥杯/方格分割/solution.md
+111
-1
data/1.算法初阶/1.蓝桥杯/方程整数解/solution.md
data/1.算法初阶/1.蓝桥杯/方程整数解/solution.md
+116
-1
data/1.算法初阶/1.蓝桥杯/翻硬币/solution.md
data/1.算法初阶/1.蓝桥杯/翻硬币/solution.md
+114
-5
未找到文件。
data/1.算法初阶/1.蓝桥杯/夺冠概率/solution.cpp
浏览文件 @
88724d3b
...
...
@@ -20,7 +20,7 @@ int main()
{
if
(
j
!=
i
&&
k
!=
i
&&
j
!=
k
)
{
sum
+=
rate
[
0
][
i
]
*
rate
[
j
][
k
];
sum
+=
rate
[
0
][
i
]
*
rate
[
j
][
k
]
*
rate
[
0
][
j
]
;
}
}
}
...
...
data/1.算法初阶/1.蓝桥杯/方格分割/solution.cpp
浏览文件 @
88724d3b
...
...
@@ -2,37 +2,37 @@
using
namespace
std
;
int
ans
;
int
dire
[][
2
]
=
{{
-
1
,
0
},
{
1
,
0
},
{
0
,
-
1
},
{
0
,
1
}};
//代表4个方向,上下左右
int
vis
[
7
][
7
];
//哪些点已被访问过
int
dire
[][
2
]
=
{{
-
1
,
0
},
{
1
,
0
},
{
0
,
-
1
},
{
0
,
1
}};
int
vis
[
7
][
7
];
void
dfs
(
int
x
,
int
y
)
{
if
(
x
==
0
||
y
==
0
||
x
==
6
||
y
==
6
)
{
//终止出口条件,当走到边缘的时候,符合题意
{
ans
++
;
return
;
}
//当前的点标注为已访问的点
vis
[
x
][
y
]
=
1
;
//对称的点也标注为已访问的点
vis
[
6
-
x
][
6
-
y
]
=
1
;
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
int
nx
=
x
+
dire
[
k
][
0
];
//横坐标的增量
int
ny
=
y
+
dire
[
k
][
1
];
//纵坐标的增量
//新坐标
int
nx
=
x
+
dire
[
k
][
0
];
int
ny
=
y
+
dire
[
k
][
1
];
if
(
nx
<
0
||
nx
>
6
||
ny
<
0
||
ny
>
6
)
continue
;
//越界,不符合
continue
;
if
(
!
vis
[
nx
][
ny
])
{
//若新的点未被访问过
dfs
(
nx
,
ny
);
//深搜
{
dfs
(
nx
,
ny
);
}
}
vis
[
x
][
y
]
=
0
;
vis
[
6
-
x
][
6
-
y
]
=
0
;
//对称
vis
[
6
-
x
][
6
-
y
]
=
0
;
}
int
main
()
{
dfs
(
3
,
3
);
//初始点
dfs
(
3
,
3
);
cout
<<
ans
/
4
<<
endl
;
return
0
;
}
data/1.算法初阶/1.蓝桥杯/方格分割/solution.md
浏览文件 @
88724d3b
...
...
@@ -15,30 +15,140 @@
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
int
ans
;
int
dire
[][
2
]
=
{{
-
1
,
0
},
{
1
,
0
},
{
0
,
-
1
},
{
0
,
1
}};
int
vis
[
7
][
7
];
```
### after
```
cpp
int
main
()
{
dfs
(
3
,
3
);
cout
<<
ans
/
4
<<
endl
;
return
0
;
}
```
## 答案
```
cpp
void
dfs
(
int
x
,
int
y
)
{
if
(
x
==
0
||
y
==
0
||
x
==
6
||
y
==
6
)
{
ans
++
;
return
;
}
vis
[
x
][
y
]
=
1
;
vis
[
6
-
x
][
6
-
y
]
=
1
;
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
int
nx
=
x
+
dire
[
k
][
0
];
int
ny
=
y
+
dire
[
k
][
1
];
if
(
nx
<
0
||
nx
>
6
||
ny
<
0
||
ny
>
6
)
continue
;
if
(
!
vis
[
nx
][
ny
])
{
dfs
(
nx
,
ny
);
}
}
vis
[
x
][
y
]
=
0
;
vis
[
6
-
x
][
6
-
y
]
=
0
;
}
```
## 选项
### A
```
cpp
void
dfs
(
int
x
,
int
y
)
{
if
(
x
==
0
||
y
==
0
||
x
==
6
||
y
==
6
)
{
ans
++
;
return
;
}
vis
[
x
][
y
]
=
1
;
vis
[
6
-
x
][
6
-
y
]
=
1
;
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
int
nx
=
x
+
dire
[
k
][
0
];
int
ny
=
y
+
dire
[
k
][
1
];
if
(
nx
<
0
||
nx
>
6
||
ny
<
0
||
ny
>
6
)
continue
;
if
(
!
vis
[
nx
][
ny
])
{
dfs
(
nx
-
1
,
ny
-
1
);
}
}
vis
[
x
][
y
]
=
0
;
vis
[
6
-
x
][
6
-
y
]
=
0
;
}
```
### B
```
cpp
void
dfs
(
int
x
,
int
y
)
{
if
(
x
==
0
||
y
==
0
||
x
==
6
||
y
==
6
)
{
ans
++
;
return
;
}
vis
[
x
][
y
]
=
1
;
vis
[
6
-
x
][
6
-
y
]
=
1
;
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
int
nx
=
x
+
dire
[
k
][
0
];
int
ny
=
y
+
dire
[
k
][
1
];
if
(
nx
<
0
||
nx
>
6
||
ny
<
0
||
ny
>
6
)
continue
;
if
(
!
vis
[
nx
][
ny
])
{
dfs
(
nx
+
1
,
ny
+
1
);
}
}
vis
[
x
][
y
]
=
0
;
vis
[
6
-
x
][
6
-
y
]
=
0
;
}
```
### C
```
cpp
void
dfs
(
int
x
,
int
y
)
{
if
(
x
==
0
||
y
==
0
||
x
==
6
||
y
==
6
)
{
ans
++
;
return
;
}
vis
[
x
][
y
]
=
1
;
vis
[
6
-
x
][
6
-
y
]
=
1
;
for
(
int
k
=
0
;
k
<
4
;
k
++
)
{
int
nx
=
x
+
dire
[
k
][
0
];
int
ny
=
y
+
dire
[
k
][
1
];
if
(
nx
<
0
||
nx
>
6
||
ny
<
0
||
ny
>
6
)
continue
;
if
(
!
vis
[
nx
][
ny
])
{
dfs
(
nx
,
ny
+
1
);
}
}
vis
[
x
][
y
]
=
0
;
vis
[
6
-
x
][
6
-
y
]
=
0
;
}
```
data/1.算法初阶/1.蓝桥杯/方程整数解/solution.md
浏览文件 @
88724d3b
...
...
@@ -25,7 +25,9 @@ No Solution
## aop
### before
```
cpp
#include <iostream>
#include <cmath>
using
namespace
std
;
```
### after
```
cpp
...
...
@@ -34,21 +36,134 @@ No Solution
## 答案
```
cpp
int
main
()
{
int
n
;
bool
flag
=
false
;
while
(
cin
>>
n
)
{
flag
=
false
;
for
(
int
i
=
1
;
i
<=
sqrt
(
n
);
i
++
)
{
for
(
int
j
=
i
;
j
<=
sqrt
(
n
);
j
++
)
{
for
(
int
k
=
j
;
k
<=
sqrt
(
n
);
k
++
)
{
if
(
i
*
i
+
j
*
j
+
k
*
k
==
n
)
{
cout
<<
i
<<
' '
<<
j
<<
' '
<<
k
<<
endl
;
flag
=
true
;
}
else
if
(
i
*
i
+
j
*
j
+
k
*
k
>
n
)
break
;
}
}
}
if
(
!
flag
)
cout
<<
"No Solution"
<<
endl
;
}
return
0
;
}
```
## 选项
### A
```
cpp
int
main
()
{
int
n
;
bool
flag
=
false
;
while
(
cin
>>
n
)
{
flag
=
false
;
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
for
(
int
j
=
i
;
j
<=
n
;
j
++
)
{
for
(
int
k
=
j
;
k
<=
n
;
k
++
)
{
if
(
i
*
i
+
j
*
j
+
k
*
k
==
n
)
{
cout
<<
i
<<
' '
<<
j
<<
' '
<<
k
<<
endl
;
flag
=
true
;
}
else
if
(
i
*
i
+
j
*
j
+
k
*
k
>
n
)
break
;
}
}
}
if
(
!
flag
)
cout
<<
"No Solution"
<<
endl
;
}
return
0
;
}
```
### B
```
cpp
int
main
()
{
int
n
;
bool
flag
=
false
;
while
(
cin
>>
n
)
{
flag
=
false
;
for
(
int
i
=
1
;
i
<
sqrt
(
n
);
i
++
)
{
for
(
int
j
=
1
;
j
<
sqrt
(
n
);
j
++
)
{
for
(
int
k
=
1
;
k
<
sqrt
(
n
);
k
++
)
{
if
(
i
*
i
+
j
*
j
+
k
*
k
==
n
)
{
cout
<<
i
<<
' '
<<
j
<<
' '
<<
k
<<
endl
;
flag
=
true
;
}
else
if
(
i
*
i
+
j
*
j
+
k
*
k
>
n
)
break
;
}
}
}
if
(
!
flag
)
cout
<<
"No Solution"
<<
endl
;
}
return
0
;
}
```
### C
```
cpp
int
main
()
{
int
n
;
bool
flag
=
false
;
while
(
cin
>>
n
)
{
flag
=
false
;
for
(
int
i
=
1
;
i
<=
sqrt
(
n
);
i
++
)
{
for
(
int
j
=
1
;
j
<=
sqrt
(
n
);
j
++
)
{
for
(
int
k
=
j
;
k
<=
sqrt
(
n
);
k
++
)
{
if
(
i
*
i
+
j
*
j
+
k
*
k
==
n
)
{
cout
<<
i
<<
' '
<<
j
<<
' '
<<
k
<<
endl
;
flag
=
true
;
}
else
if
(
i
*
i
+
j
*
j
+
k
*
k
>
n
)
break
;
}
}
}
if
(
!
flag
)
cout
<<
"No Solution"
<<
endl
;
}
return
0
;
}
```
data/1.算法初阶/1.蓝桥杯/翻硬币/solution.md
浏览文件 @
88724d3b
...
...
@@ -40,7 +40,8 @@ o****o****
## aop
### before
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
### after
```
cpp
...
...
@@ -49,21 +50,129 @@ o****o****
## 答案
```
cpp
int
main
()
{
string
a
,
b
;
cin
>>
a
>>
b
;
int
a1
=
a
.
size
(),
b1
=
b
.
size
(),
ans
=
0
;
for
(
int
i
=
0
;
i
<
a1
;
i
++
)
{
if
(
a
[
i
]
==
b
[
i
])
{
continue
;
}
else
{
ans
++
;
a
[
i
]
=
b
[
i
];
if
(
a
[
i
+
1
]
==
'*'
)
{
a
[
i
+
1
]
=
'o'
;
}
else
{
a
[
i
+
1
]
=
'*'
;
}
}
}
cout
<<
ans
<<
endl
;
return
0
;
}
```
## 选项
### A
```
cpp
int
main
()
{
string
a
,
b
;
cin
>>
a
>>
b
;
int
a1
=
a
.
size
(),
b1
=
b
.
size
(),
ans
=
0
;
for
(
int
i
=
0
;
i
<
a1
;
i
++
)
{
if
(
a
[
i
]
==
b
[
i
])
{
continue
;
}
else
{
ans
++
;
a
[
i
]
=
b
[
i
];
if
(
a
[
i
+
1
]
==
'*'
)
{
a
[
i
]
=
'o'
;
}
else
{
a
[
i
]
=
'*'
;
}
}
}
cout
<<
ans
<<
endl
;
return
0
;
}
```
### B
```
cpp
int
main
()
{
string
a
,
b
;
cin
>>
a
>>
b
;
int
a1
=
a
.
size
(),
b1
=
b
.
size
(),
ans
=
0
;
for
(
int
i
=
0
;
i
<
a1
;
i
++
)
{
if
(
a
[
i
]
==
b
[
i
])
{
continue
;
}
else
{
ans
++
;
a
[
i
]
=
b
[
i
];
if
(
a
[
i
]
==
'*'
)
{
a
[
i
+
1
]
=
'o'
;
}
else
{
a
[
i
+
1
]
=
'*'
;
}
}
}
cout
<<
ans
<<
endl
;
return
0
;
}
```
### C
```
cpp
int
main
()
{
string
a
,
b
;
cin
>>
a
>>
b
;
int
a1
=
a
.
size
(),
b1
=
b
.
size
(),
ans
=
0
;
for
(
int
i
=
0
;
i
<
a1
;
i
++
)
{
if
(
a
[
i
]
==
b
[
i
])
{
continue
;
}
else
{
ans
++
;
a
[
i
]
=
b
[
i
];
if
(
a
[
i
]
==
'*'
)
{
a
[
i
+
1
]
=
'*'
;
}
else
{
a
[
i
+
1
]
=
'o'
;
}
}
}
cout
<<
ans
<<
endl
;
return
0
;
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录