Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_algorithm
提交
62f75b25
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看板
提交
62f75b25
编写于
10月 28, 2021
作者:
每日一练社区
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update exercises
上级
7ddf3532
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
1885 addition
and
218 deletion
+1885
-218
data/1.算法初阶/1.蓝桥杯/不同子串/solution.md
data/1.算法初阶/1.蓝桥杯/不同子串/solution.md
+47
-4
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.cpp
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.cpp
+2
-2
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.md
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.md
+90
-4
data/1.算法初阶/1.蓝桥杯/乘积最大/solution.md
data/1.算法初阶/1.蓝桥杯/乘积最大/solution.md
+160
-4
data/1.算法初阶/1.蓝桥杯/凑算式/solution.md
data/1.算法初阶/1.蓝桥杯/凑算式/solution.md
+98
-4
data/1.算法初阶/1.蓝桥杯/大数乘法/solution.md
data/1.算法初阶/1.蓝桥杯/大数乘法/solution.md
+99
-2
data/1.算法初阶/1.蓝桥杯/大臣的旅费/solution.md
data/1.算法初阶/1.蓝桥杯/大臣的旅费/solution.md
+140
-5
data/1.算法初阶/1.蓝桥杯/成绩分析/desc.md
data/1.算法初阶/1.蓝桥杯/成绩分析/desc.md
+4
-3
data/1.算法初阶/1.蓝桥杯/成绩分析/solution.md
data/1.算法初阶/1.蓝桥杯/成绩分析/solution.md
+91
-6
data/1.算法初阶/1.蓝桥杯/成绩统计/solution.md
data/1.算法初阶/1.蓝桥杯/成绩统计/solution.md
+138
-4
data/1.算法初阶/1.蓝桥杯/打印图形/solution.md
data/1.算法初阶/1.蓝桥杯/打印图形/solution.md
+81
-0
data/1.算法初阶/1.蓝桥杯/打印菱形/config.json
data/1.算法初阶/1.蓝桥杯/打印菱形/config.json
+0
-7
data/1.算法初阶/1.蓝桥杯/打印菱形/desc.md
data/1.算法初阶/1.蓝桥杯/打印菱形/desc.md
+0
-21
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.cpp
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.cpp
+0
-0
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.java
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.java
+0
-25
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.md
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.md
+0
-52
data/1.算法初阶/1.蓝桥杯/承压计算/solution.cpp
data/1.算法初阶/1.蓝桥杯/承压计算/solution.cpp
+1
-1
data/1.算法初阶/1.蓝桥杯/承压计算/solution.md
data/1.算法初阶/1.蓝桥杯/承压计算/solution.md
+112
-2
data/1.算法初阶/1.蓝桥杯/抽签/solution.md
data/1.算法初阶/1.蓝桥杯/抽签/solution.md
+67
-1
data/1.算法初阶/1.蓝桥杯/搭积木/solution.md
data/1.算法初阶/1.蓝桥杯/搭积木/solution.md
+135
-5
data/1.算法初阶/1.蓝桥杯/次数差/solution.md
data/1.算法初阶/1.蓝桥杯/次数差/solution.md
+102
-5
data/1.算法初阶/1.蓝桥杯/波动数列/solution.md
data/1.算法初阶/1.蓝桥杯/波动数列/solution.md
+105
-5
data/1.算法初阶/1.蓝桥杯/测试次数/solution.md
data/1.算法初阶/1.蓝桥杯/测试次数/solution.md
+72
-6
data/1.算法初阶/1.蓝桥杯/猜字母/solution.md
data/1.算法初阶/1.蓝桥杯/猜字母/solution.md
+75
-5
data/1.算法初阶/1.蓝桥杯/猜年龄/solution.md
data/1.算法初阶/1.蓝桥杯/猜年龄/solution.md
+17
-5
data/1.算法初阶/1.蓝桥杯/超级胶水/solution.cpp
data/1.算法初阶/1.蓝桥杯/超级胶水/solution.cpp
+33
-32
data/1.算法初阶/1.蓝桥杯/超级胶水/solution.md
data/1.算法初阶/1.蓝桥杯/超级胶水/solution.md
+80
-3
data/1.算法初阶/1.蓝桥杯/错误票据/solution.md
data/1.算法初阶/1.蓝桥杯/错误票据/solution.md
+136
-5
未找到文件。
data/1.算法初阶/1.蓝桥杯/不同子串/solution.md
浏览文件 @
62f75b25
...
@@ -10,6 +10,9 @@
...
@@ -10,6 +10,9 @@
### before
### before
```
cpp
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
```
```
### after
### after
```
cpp
```
cpp
...
@@ -18,21 +21,61 @@
...
@@ -18,21 +21,61 @@
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
set
<
string
>
s
;
string
str
;
cin
>>
str
;
for
(
int
i
=
0
;
i
<
str
.
size
();
i
++
)
for
(
int
j
=
i
;
j
<
str
.
size
();
j
++
)
s
.
insert
(
str
.
substr
(
i
,
j
-
i
+
1
));
cout
<<
s
.
size
();
return
0
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
set
<
string
>
s
;
string
str
;
cin
>>
str
;
for
(
int
i
=
0
;
i
<
str
.
size
();
i
++
)
for
(
int
j
=
i
;
j
<
str
.
size
();
j
++
)
s
.
insert
(
str
.
substr
(
i
,
j
+
i
-
1
));
cout
<<
s
.
size
();
return
0
;
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
set
<
string
>
s
;
string
str
;
cin
>>
str
;
for
(
int
i
=
0
;
i
<
str
.
size
();
i
++
)
for
(
int
j
=
i
;
j
<
str
.
size
();
j
++
)
s
.
insert
(
str
.
substr
(
i
,
j
+
1
));
cout
<<
s
.
size
();
return
0
;
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
set
<
string
>
s
;
string
str
;
cin
>>
str
;
for
(
int
i
=
0
;
i
<
str
.
size
();
i
++
)
for
(
int
j
=
i
;
j
<
str
.
size
();
j
++
)
s
.
insert
(
str
.
substr
(
i
,
j
-
i
));
cout
<<
s
.
size
();
return
0
;
}
```
```
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.cpp
浏览文件 @
62f75b25
...
@@ -10,12 +10,12 @@ int main()
...
@@ -10,12 +10,12 @@ int main()
while
(
num
%
5
==
0
)
while
(
num
%
5
==
0
)
{
{
count5
++
;
count5
++
;
num
/
=
5
;
num
+
=
5
;
}
}
while
(
num
%
2
==
0
)
while
(
num
%
2
==
0
)
{
{
count2
++
;
count2
++
;
num
/
=
2
;
num
+
=
2
;
}
}
}
}
int
ans
=
count2
<
count5
?
count2
:
count5
;
int
ans
=
count2
<
count5
?
count2
:
count5
;
...
...
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.md
浏览文件 @
62f75b25
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <iostream>
using
namespace
std
;
```
```
### after
### after
```
cpp
```
cpp
...
@@ -25,21 +26,106 @@
...
@@ -25,21 +26,106 @@
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
int
count2
=
0
,
count5
=
0
;
int
num
;
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
cin
>>
num
;
while
(
num
%
5
==
0
)
{
count5
++
;
num
/=
5
;
}
while
(
num
%
2
==
0
)
{
count2
++
;
num
/=
2
;
}
}
int
ans
=
count2
<
count5
?
count2
:
count5
;
cout
<<
ans
;
return
0
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
int
count2
=
0
,
count5
=
0
;
int
num
;
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
cin
>>
num
;
while
(
num
%
5
==
0
)
{
count5
++
;
num
/=
5
;
}
while
(
num
%
2
==
0
)
{
count2
++
;
num
/=
2
;
}
}
int
ans
=
count2
<
count5
?
count5
:
count2
;
cout
<<
ans
;
return
0
;
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
int
count2
=
0
,
count5
=
0
;
int
num
;
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
cin
>>
num
;
while
(
num
%
5
==
0
)
{
count5
++
;
num
%=
5
;
}
while
(
num
%
2
==
0
)
{
count2
++
;
num
%=
2
;
}
}
int
ans
=
count2
<
count5
?
count2
:
count5
;
cout
<<
ans
;
return
0
;
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
int
count2
=
0
,
count5
=
0
;
int
num
;
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
cin
>>
num
;
while
(
num
%
5
==
0
)
{
count5
++
;
num
+=
5
;
}
while
(
num
%
2
==
0
)
{
count2
++
;
num
+=
2
;
}
}
int
ans
=
count2
<
count5
?
count2
:
count5
;
cout
<<
ans
;
return
0
;
}
```
```
data/1.算法初阶/1.蓝桥杯/乘积最大/solution.md
浏览文件 @
62f75b25
...
@@ -47,7 +47,10 @@
...
@@ -47,7 +47,10 @@
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <iostream>
#include <vector>
#include <algorithm>
using
namespace
std
;
```
```
### after
### after
```
cpp
```
cpp
...
@@ -56,21 +59,174 @@
...
@@ -56,21 +59,174 @@
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
int
n
,
k
;
long
long
ans
;
cin
>>
n
>>
k
;
vector
<
long
long
>
num
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
int
temp
;
cin
>>
temp
;
num
.
push_back
(
temp
);
}
sort
(
num
.
begin
(),
num
.
end
());
if
(
k
%
2
!=
0
)
{
ans
=
num
.
back
();
k
=
k
-
1
;
num
.
pop_back
();
}
else
ans
=
1
;
while
(
k
>
0
)
{
if
((
num
[
0
]
*
num
[
1
])
>
num
.
at
(
num
.
size
()
-
1
)
*
num
.
at
(
num
.
size
()
-
2
))
{
ans
=
ans
*
num
[
0
]
*
num
[
1
]
%
1000000009
;
num
.
erase
(
num
.
begin
(),
num
.
begin
()
+
1
);
}
else
{
ans
=
ans
*
num
.
at
(
num
.
size
()
-
1
)
*
num
.
at
(
num
.
size
()
-
2
)
%
1000000009
;
num
.
pop_back
();
num
.
pop_back
();
}
k
-=
2
;
}
cout
<<
ans
;
return
0
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
int
n
,
k
;
long
long
ans
;
cin
>>
n
>>
k
;
vector
<
long
long
>
num
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
int
temp
;
cin
>>
temp
;
num
.
push_back
(
temp
);
}
sort
(
num
.
begin
(),
num
.
end
());
if
(
k
%
2
!=
0
)
{
ans
=
num
.
back
();
k
=
k
-
1
;
num
.
pop_back
();
}
else
ans
=
1
;
while
(
k
>
0
)
{
if
((
num
[
0
]
*
num
[
1
])
>
num
.
at
(
num
.
size
())
*
num
.
at
(
num
.
size
()
-
1
))
{
ans
=
ans
*
num
[
0
]
*
num
[
1
]
%
1000000009
;
num
.
erase
(
num
.
begin
(),
num
.
begin
()
+
1
);
}
else
{
ans
=
ans
*
num
.
at
(
num
.
size
())
*
num
.
at
(
num
.
size
()
-
1
)
%
1000000009
;
num
.
pop_back
();
num
.
pop_back
();
}
k
-=
2
;
}
cout
<<
ans
;
return
0
;
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
int
n
,
k
;
long
long
ans
;
cin
>>
n
>>
k
;
vector
<
long
long
>
num
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
int
temp
;
cin
>>
temp
;
num
.
push_back
(
temp
);
}
sort
(
num
.
begin
(),
num
.
end
());
if
(
k
%
2
!=
0
)
{
ans
=
num
.
back
();
k
=
k
-
1
;
num
.
pop_back
();
}
else
ans
=
1
;
while
(
k
>
0
)
{
if
((
num
[
0
]
*
num
[
1
])
>
num
.
at
(
num
.
size
()
-
1
)
*
num
.
at
(
num
.
size
()
-
1
))
{
ans
=
ans
*
num
[
0
]
*
num
[
1
]
%
1000000009
;
num
.
erase
(
num
.
begin
(),
num
.
begin
()
+
1
);
}
else
{
ans
=
ans
*
num
.
at
(
num
.
size
()
-
1
)
%
1000000009
;
num
.
pop_back
();
num
.
pop_back
();
}
k
-=
2
;
}
cout
<<
ans
;
return
0
;
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
int
n
,
k
;
long
long
ans
;
cin
>>
n
>>
k
;
vector
<
long
long
>
num
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
int
temp
;
cin
>>
temp
;
num
.
push_back
(
temp
);
}
sort
(
num
.
begin
(),
num
.
end
());
if
(
k
%
2
!=
0
)
{
ans
=
num
.
back
();
k
=
k
-
1
;
num
.
pop_back
();
}
else
ans
=
1
;
while
(
k
>
0
)
{
if
((
num
[
0
]
*
num
[
1
])
>
num
.
at
(
num
.
size
()
-
1
)
*
num
.
at
(
num
.
size
()
-
2
))
{
ans
=
ans
*
num
[
0
]
*
num
[
1
]
%
1000000009
;
num
.
erase
(
num
.
begin
(),
num
.
begin
()
+
1
);
}
else
{
ans
=
ans
*
num
.
at
(
num
.
size
()
-
1
)
%
1000000009
;
num
.
pop_back
();
num
.
pop_back
();
}
k
-=
2
;
}
cout
<<
ans
;
return
0
;
}
```
```
data/1.算法初阶/1.蓝桥杯/凑算式/solution.md
浏览文件 @
62f75b25
...
@@ -16,30 +16,124 @@ A + —- + ——–- = 10
...
@@ -16,30 +16,124 @@ A + —- + ——–- = 10
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <stdio.h>
#include <stdbool.h>
int
ans
=
0
;
int
nums
[
10
];
bool
visited
[
10
];
void
judge
()
{
int
i
;
if
(
nums
[
0
]
+
(
double
)
nums
[
1
]
/
nums
[
2
]
+
(
double
)(
nums
[
3
]
*
100
+
nums
[
4
]
*
10
+
nums
[
5
])
/
(
nums
[
6
]
*
100
+
nums
[
7
]
*
10
+
nums
[
8
])
==
10
)
{
printf
(
"%d + %d/%d + %d%d%d/%d%d%d"
,
nums
[
0
],
nums
[
1
],
nums
[
2
],
nums
[
3
],
nums
[
4
],
nums
[
5
],
nums
[
6
],
nums
[
7
],
nums
[
8
]);
printf
(
"
\n
"
);
ans
++
;
}
}
```
```
### after
### after
```
cpp
```
cpp
int
main
()
{
dfs
(
0
);
printf
(
"%d
\n
"
,
ans
);
return
0
;
}
```
```
## 答案
## 答案
```
cpp
```
cpp
void
dfs
(
int
index
)
{
if
(
index
>=
9
)
{
judge
();
return
;
}
int
i
;
for
(
i
=
1
;
i
<
10
;
i
++
)
{
if
(
visited
[
i
]
==
false
)
{
visited
[
i
]
=
true
;
nums
[
index
]
=
i
;
dfs
(
index
+
1
);
visited
[
i
]
=
false
;
}
}
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
void
dfs
(
int
index
)
{
if
(
index
>=
9
)
{
judge
();
return
;
}
int
i
;
for
(
i
=
1
;
i
<
10
;
i
++
)
{
if
(
visited
[
i
]
==
false
)
{
visited
[
i
]
=
true
;
nums
[
index
]
=
i
;
dfs
(
index
);
visited
[
i
]
=
false
;
}
}
}
```
```
### B
### B
```
cpp
```
cpp
void
dfs
(
int
index
)
{
if
(
index
>=
9
)
{
judge
();
return
;
}
int
i
;
for
(
i
=
1
;
i
<
10
;
i
++
)
{
if
(
visited
[
i
]
==
true
)
{
visited
[
i
]
=
false
;
nums
[
index
]
=
i
;
dfs
(
index
);
visited
[
i
]
=
true
;
}
}
}
```
```
### C
### C
```
cpp
```
cpp
void
dfs
(
int
index
)
{
if
(
index
>=
9
)
{
judge
();
return
;
}
int
i
;
for
(
i
=
1
;
i
<
10
;
i
++
)
{
if
(
visited
[
i
]
==
true
)
{
visited
[
i
]
=
false
;
nums
[
index
]
=
i
;
dfs
(
index
+
1
);
visited
[
i
]
=
true
;
}
}
}
```
```
data/1.算法初阶/1.蓝桥杯/大数乘法/solution.md
浏览文件 @
62f75b25
# 大数乘法
# 大数乘法
对于32位字长的机器,大约超过20亿,用int类型就无法表示了,我们可以选择int64类型,但无论怎样扩展,固定的整数类型总是有表达的极限!如果对超级大整数进行精确运算呢?一个简单的办法是:仅仅使用现有类型,但是把大整数的运算化解为若干小整数的运算,即所谓:“分块法”。
对于32位字长的机器,大约超过20亿,用int类型就无法表示了,我们可以选择int64类型,但无论怎样扩展,固定的整数类型总是有表达的极限!如果对超级大整数进行精确运算呢?一个简单的办法是:仅仅使用现有类型,但是把大整数的运算化解为若干小整数的运算,即所谓:“分块法”。
![](
https:
//img-blog.csdn.net/20160125091111485
)
![](
https:
上图表示了分块乘法的原理。可以把大数分成多段(此处为2段)小数,然后用小数的多次运算组合表示一个大数。可以根据int的承载能力规定小块的大小,比如要把int分成2段,则小块可取10000为上限值。注意,小块在进行纵向累加后,需要进行进位校正。
上图表示了分块乘法的原理。可以把大数分成多段(此处为2段)小数,然后用小数的多次运算组合表示一个大数。可以根据int的承载能力规定小块的大小,比如要把int分成2段,则小块可取10000为上限值。注意,小块在进行纵向累加后,需要进行进位校正。
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <stdio.h>
```
```
### after
### after
```
cpp
```
cpp
int
main
(
int
argc
,
char
*
argv
[])
{
int
x
[]
=
{
0
,
0
,
0
,
0
};
bigmul
(
87654321
,
12345678
,
x
);
printf
(
"%d%d%d%d
\n
"
,
x
[
0
],
x
[
1
],
x
[
2
],
x
[
3
]);
return
0
;
}
```
```
## 答案
## 答案
```
cpp
```
cpp
void
bigmul
(
int
x
,
int
y
,
int
r
[])
{
int
base
=
10000
;
int
x2
=
x
/
base
;
int
x1
=
x
%
base
;
int
y2
=
y
/
base
;
int
y1
=
y
%
base
;
int
n1
=
x1
*
y1
;
int
n2
=
x1
*
y2
;
int
n3
=
x2
*
y1
;
int
n4
=
x2
*
y2
;
r
[
3
]
=
n1
%
base
;
r
[
2
]
=
n1
/
base
+
n2
%
base
+
n3
%
base
;
r
[
1
]
=
n2
/
base
+
n3
/
base
+
n4
%
base
;
r
[
0
]
=
n4
/
base
;
r
[
1
]
+=
r
[
2
]
/
base
;
r
[
2
]
=
r
[
2
]
%
base
;
r
[
0
]
+=
r
[
1
]
/
base
;
r
[
1
]
=
r
[
1
]
%
base
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
void
bigmul
(
int
x
,
int
y
,
int
r
[])
{
int
base
=
10000
;
int
x2
=
x
/
base
;
int
x1
=
x
%
base
;
int
y2
=
y
/
base
;
int
y1
=
y
%
base
;
int
n1
=
x1
*
y1
;
int
n2
=
x1
*
y2
;
int
n3
=
x2
*
y1
;
int
n4
=
x2
*
y2
;
r
[
3
]
=
n1
%
base
;
r
[
2
]
=
n1
/
base
+
n2
%
base
+
n3
%
base
;
r
[
1
]
=
n2
/
base
+
n3
/
base
+
n4
%
base
;
r
[
0
]
=
n4
/
base
;
r
[
1
]
+=
r
[
2
]
%
base
;
r
[
2
]
=
r
[
2
]
/
base
;
r
[
0
]
+=
r
[
1
]
/
base
;
r
[
1
]
=
r
[
1
]
%
base
;
}
```
```
### B
### B
```
cpp
```
cpp
void
bigmul
(
int
x
,
int
y
,
int
r
[])
{
int
base
=
10000
;
int
x2
=
x
/
base
;
int
x1
=
x
%
base
;
int
y2
=
y
/
base
;
int
y1
=
y
%
base
;
int
n1
=
x1
*
y1
;
int
n2
=
x1
*
y2
;
int
n3
=
x2
*
y1
;
int
n4
=
x2
*
y2
;
r
[
3
]
=
n1
%
base
;
r
[
2
]
=
n1
/
base
+
n2
%
base
+
n3
%
base
;
r
[
1
]
=
n2
/
base
+
n3
/
base
+
n4
/
base
;
r
[
0
]
=
n4
/
base
;
r
[
1
]
+=
r
[
2
]
/
base
;
r
[
2
]
=
r
[
2
]
%
base
;
r
[
0
]
+=
r
[
1
]
/
base
;
r
[
1
]
=
r
[
1
]
%
base
;
}
```
```
### C
### C
```
cpp
```
cpp
void
bigmul
(
int
x
,
int
y
,
int
r
[])
{
int
base
=
10000
;
int
x2
=
x
/
base
;
int
x1
=
x
%
base
;
int
y2
=
y
/
base
;
int
y1
=
y
%
base
;
int
n1
=
x1
*
y1
;
int
n2
=
x1
*
y2
;
int
n3
=
x2
*
y1
;
int
n4
=
x2
*
y2
;
r
[
3
]
=
n1
%
base
;
r
[
2
]
=
n1
/
base
+
n2
%
base
+
n3
%
base
;
r
[
1
]
=
n2
/
base
+
n3
%
base
+
n4
/
base
;
r
[
0
]
=
n4
/
base
;
r
[
1
]
+=
r
[
2
]
/
base
;
r
[
2
]
=
r
[
2
]
%
base
;
r
[
0
]
+=
r
[
1
]
/
base
;
r
[
1
]
=
r
[
1
]
%
base
;
}
```
```
data/1.算法初阶/1.蓝桥杯/大臣的旅费/solution.md
浏览文件 @
62f75b25
...
@@ -42,30 +42,165 @@ J大臣想知道:他从某一个城市出发,中间不休息,到达另一
...
@@ -42,30 +42,165 @@ J大臣想知道:他从某一个城市出发,中间不休息,到达另一
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
#define mem(a, b) memset(a, b, sizeof(a))
#define ll long long
const
double
eps
=
3e-8
;
const
int
mod
=
10
;
const
int
maxn
=
10005
;
vector
<
int
>
ed
[
maxn
];
ll
edge
[
maxn
][
maxn
];
ll
dis
[
maxn
];
ll
sum
=
0
;
```
```
### after
### after
```
cpp
```
cpp
int
main
()
{
int
n
,
a
,
b
;
ll
c
;
scanf
(
"%d"
,
&
n
);
for
(
int
i
=
1
;
i
<
n
;
i
++
)
{
scanf
(
"%d%d%lld"
,
&
a
,
&
b
,
&
c
);
ed
[
a
].
push_back
(
b
);
ed
[
b
].
push_back
(
a
);
edge
[
a
][
b
]
=
c
;
edge
[
b
][
a
]
=
c
;
}
int
starta
=
1
;
int
endnode
,
startnode
;
sum
=
0
;
endnode
=
bfs
(
starta
);
sum
=
0
;
startnode
=
bfs
(
endnode
);
double
ans
=
sum
*
(
sum
+
1.0
)
/
2
+
10.0
*
sum
;
printf
(
"%.0f
\n
"
,
ans
);
}
```
```
## 答案
## 答案
```
cpp
```
cpp
int
bfs
(
int
node
)
{
mem
(
dis
,
-
1
);
queue
<
int
>
que
;
que
.
push
(
node
);
int
ans
=
node
;
dis
[
node
]
=
0
;
while
(
!
que
.
empty
())
{
int
now
=
que
.
front
();
que
.
pop
();
for
(
int
i
=
0
;
i
<
ed
[
now
].
size
();
i
++
)
{
int
temp
=
ed
[
now
][
i
];
if
(
dis
[
temp
]
<
0
)
{
dis
[
temp
]
=
dis
[
now
]
+
edge
[
now
][
temp
];
if
(
dis
[
temp
]
>
sum
)
{
ans
=
temp
;
sum
=
dis
[
temp
];
}
que
.
push
(
temp
);
}
}
}
return
ans
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
bfs
(
int
node
)
{
mem
(
dis
,
-
1
);
queue
<
int
>
que
;
que
.
push
(
node
);
int
ans
=
node
;
dis
[
node
]
=
0
;
while
(
!
que
.
empty
())
{
int
now
=
que
.
front
();
que
.
pop
();
for
(
int
i
=
0
;
i
<
ed
[
now
].
size
();
i
++
)
{
int
temp
=
ed
[
now
][
i
];
if
(
dis
[
temp
]
<
0
)
{
dis
[
temp
]
=
dis
[
now
]
+
edge
[
now
][
temp
];
ans
=
temp
;
sum
=
dis
[
temp
];
que
.
push
(
temp
);
}
}
}
return
ans
;
}
```
```
### B
### B
```
cpp
```
cpp
int
bfs
(
int
node
)
{
mem
(
dis
,
-
1
);
queue
<
int
>
que
;
que
.
push
(
node
);
int
ans
=
node
;
dis
[
node
]
=
0
;
while
(
!
que
.
empty
())
{
int
now
=
que
.
front
();
que
.
pop
();
for
(
int
i
=
0
;
i
<
ed
[
now
].
size
();
i
++
)
{
int
temp
=
ed
[
now
][
i
];
dis
[
temp
]
=
dis
[
now
]
+
edge
[
now
][
temp
];
ans
=
temp
;
sum
=
dis
[
temp
];
que
.
push
(
temp
);
}
}
return
ans
;
}
```
```
### C
### C
```
cpp
```
cpp
int
bfs
(
int
node
)
{
mem
(
dis
,
-
1
);
queue
<
int
>
que
;
que
.
push
(
node
);
int
ans
=
node
;
dis
[
node
]
=
0
;
while
(
!
que
.
empty
())
{
int
now
=
que
.
front
();
que
.
pop
();
for
(
int
i
=
0
;
i
<
ed
[
now
].
size
();
i
++
)
{
int
temp
=
ed
[
now
][
i
];
if
(
dis
[
temp
]
<
0
)
{
dis
[
temp
]
=
dis
[
now
]
+
edge
[
now
][
temp
];
if
(
dis
[
temp
]
<
sum
)
{
ans
=
temp
;
sum
=
dis
[
temp
];
}
que
.
push
(
temp
);
}
}
}
return
ans
;
}
```
```
data/1.算法初阶/1.蓝桥杯/成绩分析/desc.md
浏览文件 @
62f75b25
#### 问题描述
#### 问题描述
小蓝给学生们组织了一场考试,卷面总分为
分,每个学生的得分都是一个 到
的整数。
小蓝给学生们组织了一场考试,卷面总分为
100分,每个学生的得分都是一个0到100
的整数。
请计算这次考试的最高分、最低分和平均分。
请计算这次考试的最高分、最低分和平均分。
#### 输入格式
#### 输入格式
输入的第一行包含一个整数
,表示考试人数。
输入的第一行包含一个整数
n
,表示考试人数。
接下来
行,每行包含一个 至
的整数,表示一个学生的得分。
接下来
n行,每行包含一个0至100
的整数,表示一个学生的得分。
#### 输出格式
#### 输出格式
输出三行。
输出三行。
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#### 样例输入
#### 样例输入
```
```
7
80
80
92
92
56
56
...
...
data/1.算法初阶/1.蓝桥杯/成绩分析/solution.md
浏览文件 @
62f75b25
# 成绩分析
# 成绩分析
#### 问题描述
#### 问题描述
小蓝给学生们组织了一场考试,卷面总分为
分,每个学生的得分都是一个 到
的整数。
小蓝给学生们组织了一场考试,卷面总分为
100分,每个学生的得分都是一个0到100
的整数。
请计算这次考试的最高分、最低分和平均分。
请计算这次考试的最高分、最低分和平均分。
#### 输入格式
#### 输入格式
输入的第一行包含一个整数
,表示考试人数。
输入的第一行包含一个整数
n
,表示考试人数。
接下来
行,每行包含一个 至
的整数,表示一个学生的得分。
接下来
n行,每行包含一个0至100
的整数,表示一个学生的得分。
#### 输出格式
#### 输出格式
输出三行。
输出三行。
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#### 样例输入
#### 样例输入
```
```
7
80
80
92
92
56
56
...
@@ -39,7 +40,10 @@
...
@@ -39,7 +40,10 @@
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <stdio.h>
#include <iostream>
using
namespace
std
;
```
```
### after
### after
```
cpp
```
cpp
...
@@ -48,21 +52,102 @@
...
@@ -48,21 +52,102 @@
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
int
sum
=
0
;
int
top
=
0
;
int
low
=
100
;
int
score
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
cin
>>
score
;
if
(
score
>
top
)
top
=
score
;
if
(
score
<
low
)
low
=
score
;
sum
+=
score
;
}
printf
(
"%d
\n
%d
\n
%.2lf"
,
top
,
low
,
(
sum
*
1.0
/
n
));
return
0
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
int
sum
=
0
;
int
top
=
0
;
int
low
=
100
;
int
score
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
cin
>>
score
;
if
(
score
>
top
)
top
=
score
;
if
(
score
<
low
)
low
=
score
;
sum
+=
score
;
}
printf
(
"%d
\n
%d
\n
%.f"
,
top
,
low
,
(
sum
*
1.0
/
n
));
return
0
;
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
int
sum
=
0
;
int
top
=
0
;
int
low
=
100
;
int
score
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
cin
>>
score
;
if
(
score
>
top
)
score
=
top
;
if
(
score
<
low
)
score
=
low
;
sum
+=
score
;
}
printf
(
"%d
\n
%d
\n
%.2lf"
,
top
,
low
,
(
sum
*
1.0
/
n
));
return
0
;
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
int
sum
=
0
;
int
top
=
0
;
int
low
=
100
;
int
score
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
cin
>>
score
;
if
(
score
<
top
)
top
=
score
;
if
(
score
>
low
)
low
=
score
;
sum
+=
score
;
}
printf
(
"%d
\n
%d
\n
%d"
,
top
,
low
,
(
sum
/
n
));
return
0
;
}
```
```
data/1.算法初阶/1.蓝桥杯/成绩统计/solution.md
浏览文件 @
62f75b25
...
@@ -20,7 +20,8 @@ yx1
...
@@ -20,7 +20,8 @@ yx1
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <iostream>
using
namespace
std
;
```
```
### after
### after
```
cpp
```
cpp
...
@@ -29,21 +30,154 @@ yx1
...
@@ -29,21 +30,154 @@ yx1
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
struct
student
{
string
xm
;
int
xh
;
double
yy
;
double
sx
;
double
cpp
;
};
student
a
[
1000
];
int
n
;
double
sum
=
0
,
min
=
301
,
max
=
0
;
string
mins
,
maxs
;
cin
>>
n
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
cin
>>
a
[
i
].
xm
>>
a
[
i
].
xh
>>
a
[
i
].
yy
>>
a
[
i
].
sx
>>
a
[
i
].
cpp
;
sum
=
a
[
i
].
yy
+
a
[
i
].
sx
+
a
[
i
].
cpp
;
if
(
min
>
sum
)
{
min
=
sum
;
mins
=
a
[
i
].
xm
;
}
if
(
max
<
sum
)
{
max
=
sum
;
maxs
=
a
[
i
].
xm
;
}
}
cout
<<
maxs
<<
endl
<<
mins
;
return
0
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
struct
student
{
string
xm
;
int
xh
;
double
yy
;
double
sx
;
double
cpp
;
};
student
a
[
1000
];
int
n
;
double
sum
=
0
,
min
=
301
,
max
=
0
;
string
mins
,
maxs
;
cin
>>
n
;
for
(
int
i
=
1
;
i
<
n
;
i
++
)
{
cin
>>
a
[
i
].
xm
>>
a
[
i
].
xh
>>
a
[
i
].
yy
>>
a
[
i
].
sx
>>
a
[
i
].
cpp
;
sum
=
a
[
i
].
yy
+
a
[
i
].
sx
+
a
[
i
].
cpp
;
if
(
min
>
sum
)
{
min
=
sum
;
mins
=
a
[
i
].
xm
;
}
if
(
max
<
sum
)
{
max
=
sum
;
maxs
=
a
[
i
].
xm
;
}
}
cout
<<
maxs
<<
endl
<<
mins
;
return
0
;
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
struct
student
{
string
xm
;
int
xh
;
double
yy
;
double
sx
;
double
cpp
;
};
student
a
[
1000
];
int
n
;
double
sum
=
0
,
min
=
301
,
max
=
0
;
string
mins
,
maxs
;
cin
>>
n
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
cin
>>
a
[
i
].
xm
>>
a
[
i
].
xh
>>
a
[
i
].
yy
>>
a
[
i
].
sx
>>
a
[
i
].
cpp
;
sum
=
a
[
i
].
yy
+
a
[
i
].
sx
+
a
[
i
].
cpp
;
if
(
min
>
sum
)
{
min
=
sum
;
mins
=
a
[
i
]
->
xm
;
}
if
(
max
<
sum
)
{
max
=
sum
;
maxs
=
a
[
i
]
->
xm
;
}
cout
<<
maxs
<<
endl
<<
mins
;
return
0
;
}
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
struct
student
{
string
xm
;
int
xh
;
double
yy
;
double
sx
;
double
cpp
;
};
student
a
[
1000
];
int
n
;
double
sum
=
0
,
min
=
301
,
max
=
0
;
string
mins
,
maxs
;
cin
>>
n
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
cin
>>
a
[
i
].
xm
>>
a
[
i
].
xh
>>
a
[
i
].
yy
>>
a
[
i
].
sx
>>
a
[
i
].
cpp
;
sum
=
a
[
i
].
yy
+
a
[
i
].
sx
+
a
[
i
].
cpp
;
if
(
min
>
sum
)
{
min
=
sum
;
mins
=
a
[
i
].
xm
;
}
if
(
max
<
sum
)
{
max
=
sum
;
maxs
=
a
[
i
].
xm
;
}
}
cout
<<
mins
<<
endl
<<
maxs
;
return
0
;
}
```
```
data/1.算法初阶/1.蓝桥杯/打印图形/solution.md
浏览文件 @
62f75b25
...
@@ -63,30 +63,111 @@ ran=6
...
@@ -63,30 +63,111 @@ ran=6
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <cstdio>
#define N 70
```
```
### after
### after
```
cpp
```
cpp
int
main
()
{
char
a
[
N
][
N
];
int
i
,
j
;
for
(
i
=
0
;
i
<
N
;
i
++
)
for
(
j
=
0
;
j
<
N
;
j
++
)
a
[
i
][
j
]
=
' '
;
f
(
a
,
4
,
0
,
0
);
for
(
i
=
0
;
i
<
N
;
i
++
)
{
for
(
j
=
0
;
j
<
N
;
j
++
)
printf
(
"%c"
,
a
[
i
][
j
]);
printf
(
"
\n
"
);
}
return
0
;
}
```
```
## 答案
## 答案
```
cpp
```
cpp
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
if
(
rank
==
1
)
{
a
[
row
][
col
]
=
'*'
;
return
;
}
int
w
=
1
;
int
i
;
for
(
i
=
0
;
i
<
rank
-
1
;
i
++
)
w
*=
2
;
f
(
a
,
rank
-
1
,
row
,
col
+
w
/
2
);
f
(
a
,
rank
-
1
,
row
+
w
/
2
,
col
);
f
(
a
,
rank
-
1
,
row
+
w
/
2
,
col
+
w
);
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
if
(
rank
==
1
)
{
a
[
row
][
col
]
=
'*'
;
return
;
}
int
w
=
1
;
int
i
;
for
(
i
=
0
;
i
<
rank
;
i
++
)
w
*=
2
;
f
(
a
,
rank
-
1
,
row
,
col
+
w
/
2
);
f
(
a
,
rank
-
1
,
row
+
w
/
2
,
col
);
f
(
a
,
rank
-
1
,
row
+
w
/
2
,
col
+
w
);
}
```
```
### B
### B
```
cpp
```
cpp
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
if
(
rank
==
1
)
{
a
[
row
][
col
]
=
'*'
;
return
;
}
int
w
=
1
;
int
i
;
for
(
i
=
0
;
i
<
rank
-
1
;
i
++
)
w
*=
2
;
f
(
a
,
rank
+
1
,
row
,
col
+
w
/
2
);
f
(
a
,
rank
+
1
,
row
+
w
/
2
,
col
);
f
(
a
,
rank
+
1
,
row
+
w
/
2
,
col
+
w
);
}
```
```
### C
### C
```
cpp
```
cpp
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
if
(
rank
==
1
)
{
a
[
row
][
col
]
=
'*'
;
return
;
}
int
w
=
0
;
int
i
;
for
(
i
=
0
;
i
<
rank
-
1
;
i
++
)
w
*=
2
;
f
(
a
,
rank
-
1
,
row
,
col
+
w
/
2
);
f
(
a
,
rank
-
1
,
row
+
w
/
2
,
col
);
f
(
a
,
rank
-
1
,
row
+
w
/
2
,
col
+
w
);
}
```
```
data/1.算法初阶/1.蓝桥杯/打印菱形/config.json
已删除
100644 → 0
浏览文件 @
7ddf3532
{
"node_id"
:
"569d5e11c4fc5de7844053d9a733c5e8"
,
"keywords"
:
[],
"children"
:
[],
"export"
:
[]
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/打印菱形/desc.md
已删除
100644 → 0
浏览文件 @
7ddf3532
给出菱形的边长,在控制台上打印出一个菱形来。
为了便于比对空格,我们把空格用句点代替。
当边长为8时,菱形为:
```
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
```
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.cpp
已删除
100644 → 0
浏览文件 @
7ddf3532
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.java
已删除
100644 → 0
浏览文件 @
7ddf3532
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
f
(
8
);
}
public
static
void
f
(
int
n
)
{
String
s
=
"*"
;
for
(
int
i
=
0
;
i
<
2
*
n
-
3
;
i
++)
s
+=
"."
;
s
+=
"*"
;
String
s1
=
s
+
"\n"
;
String
s2
=
""
;
for
(
int
i
=
0
;
i
<
n
-
1
;
i
++)
{
s
=
"."
+
s
.
substring
(
0
,
s
.
length
()
-
3
)
+
"*"
;
// 填空
s1
=
s
+
"\n"
+
s1
;
s2
+=
s
+
"\n"
;
}
System
.
out
.
println
(
s1
+
s2
);
}
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/打印菱形/solution.md
已删除
100644 → 0
浏览文件 @
7ddf3532
# 打印菱形
给出菱形的边长,在控制台上打印出一个菱形来。
为了便于比对空格,我们把空格用句点代替。
当边长为8时,菱形为:
```
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
```
## aop
### before
```
cpp
```
### after
```
cpp
```
## 答案
```
cpp
```
## 选项
### A
```
cpp
```
### B
```
cpp
```
### C
```
cpp
```
data/1.算法初阶/1.蓝桥杯/承压计算/solution.cpp
浏览文件 @
62f75b25
...
@@ -21,7 +21,7 @@ int main()
...
@@ -21,7 +21,7 @@ int main()
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
{
a
[
i
+
1
][
j
]
+=
(
0.5
*
a
[
i
][
j
]);
a
[
i
+
1
][
j
]
+=
(
0.5
*
a
[
i
][
j
]);
a
[
i
+
1
][
j
+
1
]
+=
(
0.5
*
a
[
i
][
j
]);
a
[
i
][
j
+
1
]
+=
(
0.5
*
a
[
i
][
j
]);
}
}
}
}
double
minn
=
1000000000
,
maxx
=
-
1
;
double
minn
=
1000000000
,
maxx
=
-
1
;
...
...
data/1.算法初阶/1.蓝桥杯/承压计算/solution.md
浏览文件 @
62f75b25
...
@@ -54,6 +54,14 @@ X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
...
@@ -54,6 +54,14 @@ X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using
namespace
std
;
typedef
long
long
ll
;
const
ll
maxn
=
1e6
+
50
;
double
a
[
1050
][
1050
];
```
```
### after
### after
...
@@ -63,21 +71,123 @@ X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
...
@@ -63,21 +71,123 @@ X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
scanf
(
"%lf"
,
&
a
[
i
][
j
]);
}
}
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
a
[
i
+
1
][
j
]
+=
(
0.5
*
a
[
i
][
j
]);
a
[
i
+
1
][
j
+
1
]
+=
(
0.5
*
a
[
i
][
j
]);
}
}
double
minn
=
1000000000
,
maxx
=
-
1
;
for
(
ll
i
=
1
;
i
<=
30
;
i
++
)
{
maxx
=
max
(
maxx
,
a
[
30
][
i
]);
minn
=
min
(
minn
,
a
[
30
][
i
]);
printf
(
"%lf
\n
"
,
a
[
30
][
i
]);
}
printf
(
"%lf
\n
"
,
maxx
*
2086458231
/
minn
);
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
scanf
(
"%lf"
,
&
a
[
i
][
j
]);
}
}
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
a
[
i
+
1
][
j
]
+=
(
0.5
*
a
[
i
][
j
]);
a
[
i
+
1
][
j
+
1
]
+=
(
0.5
*
a
[
i
][
j
]);
}
}
double
minn
=
1000000000
,
maxx
=
-
1
;
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
maxx
=
max
(
maxx
,
a
[
30
][
i
]);
minn
=
min
(
minn
,
a
[
30
][
i
]);
printf
(
"%lf
\n
"
,
a
[
30
][
i
]);
}
printf
(
"%lf
\n
"
,
maxx
*
2086458231
/
minn
);
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
scanf
(
"%lf"
,
&
a
[
i
][
j
]);
}
}
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
a
[
i
+
1
][
j
]
=
(
0.5
*
a
[
i
][
j
]);
a
[
i
+
1
][
j
+
1
]
=
(
0.5
*
a
[
i
][
j
]);
}
}
double
minn
=
1000000000
,
maxx
=
-
1
;
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
maxx
=
max
(
maxx
,
a
[
30
][
i
]);
minn
=
min
(
minn
,
a
[
30
][
i
]);
printf
(
"%lf
\n
"
,
a
[
30
][
i
]);
}
printf
(
"%lf
\n
"
,
maxx
*
2086458231
/
minn
);
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
scanf
(
"%lf"
,
&
a
[
i
][
j
]);
}
}
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
a
[
i
+
1
][
j
]
+=
(
0.5
*
a
[
i
][
j
]);
a
[
i
][
j
+
1
]
+=
(
0.5
*
a
[
i
][
j
]);
}
}
double
minn
=
1000000000
,
maxx
=
-
1
;
for
(
ll
i
=
1
;
i
<=
30
;
i
++
)
{
maxx
=
max
(
maxx
,
a
[
30
][
i
]);
minn
=
min
(
minn
,
a
[
30
][
i
]);
printf
(
"%lf
\n
"
,
a
[
30
][
i
]);
}
printf
(
"%lf
\n
"
,
maxx
*
2086458231
/
minn
);
}
```
```
data/1.算法初阶/1.蓝桥杯/抽签/solution.md
浏览文件 @
62f75b25
...
@@ -36,30 +36,96 @@ C国最多可以派出2人。
...
@@ -36,30 +36,96 @@ C国最多可以派出2人。
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <iostream>
using
namespace
std
;
int
a
[
10000
],
N
,
i
,
ans
=
0
;
```
```
### after
### after
```
cpp
```
cpp
int
main
()
{
cin
>>
N
;
for
(
i
=
0
;
i
<
N
;
i
++
)
{
cin
>>
a
[
i
];
}
findAns
(
a
,
0
,
0
);
cout
<<
ans
<<
endl
;
return
0
;
}
```
```
## 答案
## 答案
```
cpp
```
cpp
void
findAns
(
int
a
[],
int
start
,
int
An
)
{
if
(
start
==
N
)
{
if
(
An
==
5
)
ans
++
;
return
;
}
for
(
i
=
0
;
i
<=
a
[
start
];
i
++
)
{
findAns
(
a
,
start
+
1
,
An
+
i
);
}
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
void
findAns
(
int
a
[],
int
start
,
int
An
)
{
if
(
start
==
N
)
{
if
(
An
==
5
)
ans
++
;
return
;
}
for
(
i
=
0
;
i
<=
a
[
start
];
i
++
)
{
findAns
(
a
,
start
+
1
,
An
);
}
}
```
```
### B
### B
```
cpp
```
cpp
void
findAns
(
int
a
[],
int
start
,
int
An
)
{
if
(
start
==
N
)
{
if
(
An
==
5
)
ans
++
;
return
;
}
for
(
i
=
0
;
i
<=
a
[
start
];
i
++
)
{
findAns
(
a
,
start
,
An
+
i
);
}
}
```
```
### C
### C
```
cpp
```
cpp
void
findAns
(
int
a
[],
int
start
,
int
An
)
{
if
(
start
==
N
)
{
if
(
An
==
5
)
ans
++
;
return
;
}
for
(
i
=
0
;
i
<=
a
[
start
];
i
++
)
{
findAns
(
a
,
start
,
An
+
1
);
}
}
```
```
data/1.算法初阶/1.蓝桥杯/搭积木/solution.md
浏览文件 @
62f75b25
...
@@ -25,30 +25,160 @@
...
@@ -25,30 +25,160 @@
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <bits/stdc++.h>
using
namespace
std
;
int
row
=
4
,
col
;
int
seq
[
5
][
8
];
int
tmp
[
11
];
int
cnt
=
0
;
bool
used
[
10
];
void
change
()
{
int
cur
=
1
;
for
(
int
i
=
1
;
i
<=
row
;
++
i
)
{
for
(
int
j
=
1
;
j
<=
i
;
++
j
)
{
seq
[
i
][
j
]
=
tmp
[
cur
++
];
}
}
}
bool
judge
()
{
for
(
int
i
=
1
;
i
<=
row
-
1
;
++
i
)
{
for
(
int
j
=
1
;
j
<=
i
;
++
j
)
{
if
(
seq
[
i
][
j
]
>
seq
[
i
+
1
][
j
]
||
seq
[
i
][
j
]
>
seq
[
i
+
1
][
j
+
1
])
return
false
;
}
}
return
true
;
}
int
ans
=
0
;
```
```
### after
### after
```
cpp
```
cpp
int
main
()
{
memset
(
used
,
false
,
sizeof
(
used
));
dfs
(
1
);
cout
<<
cnt
<<
endl
;
return
0
;
}
```
```
## 答案
## 答案
```
cpp
```
cpp
void
dfs
(
int
idx
)
{
if
(
idx
==
11
)
{
change
();
if
(
judge
())
{
cnt
++
;
return
;
}
return
;
}
for
(
int
i
=
0
;
i
<=
9
;
++
i
)
{
if
(
!
used
[
i
])
{
tmp
[
idx
]
=
i
;
used
[
i
]
=
true
;
dfs
(
idx
+
1
);
used
[
i
]
=
false
;
}
}
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
void
dfs
(
int
idx
)
{
if
(
idx
==
11
)
{
change
();
if
(
judge
())
{
cnt
++
;
return
;
}
return
;
}
for
(
int
i
=
0
;
i
<=
9
;
++
i
)
{
if
(
!
used
[
i
])
{
tmp
[
idx
]
=
i
;
used
[
i
]
=
true
;
dfs
(
idx
);
used
[
i
]
=
false
;
}
}
}
```
```
### B
### B
```
cpp
```
cpp
void
dfs
(
int
idx
)
{
if
(
idx
==
11
)
{
change
();
if
(
judge
())
{
cnt
++
;
return
;
}
return
;
}
for
(
int
i
=
0
;
i
<=
9
;
++
i
)
{
if
(
!
used
[
i
])
{
tmp
[
idx
]
=
i
;
used
[
i
]
=
false
;
dfs
(
idx
);
used
[
i
]
=
true
;
}
}
}
```
```
### C
### C
```
cpp
```
cpp
void
dfs
(
int
idx
)
{
if
(
idx
==
11
)
{
change
();
if
(
judge
())
{
cnt
++
;
return
;
}
return
;
}
for
(
int
i
=
0
;
i
<=
9
;
++
i
)
{
if
(
!
used
[
i
])
{
tmp
[
idx
]
=
i
;
used
[
i
]
=
false
;
dfs
(
idx
+
1
);
used
[
i
]
=
true
;
}
}
}
```
```
data/1.算法初阶/1.蓝桥杯/次数差/solution.md
浏览文件 @
62f75b25
...
@@ -37,7 +37,8 @@ bbccccddaaaacccc
...
@@ -37,7 +37,8 @@ bbccccddaaaacccc
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <stdio.h>
#include <string.h>
```
```
### after
### after
```
cpp
```
cpp
...
@@ -46,21 +47,117 @@ bbccccddaaaacccc
...
@@ -46,21 +47,117 @@ bbccccddaaaacccc
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
char
s
[
1000
];
scanf
(
"%s"
,
&
s
);
int
len
=
strlen
(
s
);
int
helper
[
256
]
=
{
0
};
int
max
=
0
,
min
=
len
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
helper
[
s
[
i
]]
++
;
}
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
if
(
helper
[
i
]
>
max
)
{
max
=
helper
[
i
];
}
if
(
helper
[
i
]
<
min
&&
helper
[
i
]
!=
0
)
{
min
=
helper
[
i
];
}
}
printf
(
"%d
\n
"
,
max
-
min
);
return
0
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
char
s
[
1000
];
scanf
(
"%s"
,
&
s
);
int
len
=
strlen
(
s
);
int
helper
[
256
]
=
{
0
};
int
max
=
0
,
min
=
len
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
helper
[
s
[
i
]]
++
;
}
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
if
(
helper
[
i
]
>
max
)
{
max
=
helper
[
i
];
}
if
(
helper
[
i
]
<
min
)
{
min
=
helper
[
i
];
}
}
printf
(
"%d
\n
"
,
max
-
min
);
return
0
;
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
char
s
[
1000
];
scanf
(
"%s"
,
&
s
);
int
len
=
strlen
(
s
);
int
helper
[
256
]
=
{
0
};
int
max
=
0
,
min
=
len
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
helper
[
s
[
i
]]
++
;
}
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
if
(
helper
[
i
]
>
max
)
{
max
=
helper
[
i
];
}
if
(
helper
[
i
]
<
min
&&
helper
[
i
]
==
0
)
{
min
=
helper
[
i
];
}
}
printf
(
"%d
\n
"
,
max
-
min
);
return
0
;
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
char
s
[
1000
];
scanf
(
"%s"
,
&
s
);
int
len
=
strlen
(
s
);
int
helper
[
256
]
=
{
0
};
int
max
=
0
,
min
=
len
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
helper
[
s
[
i
]]
++
;
}
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
if
(
helper
[
i
]
<
max
)
{
max
=
helper
[
i
];
}
if
(
helper
[
i
]
>
min
)
{
min
=
helper
[
i
];
}
}
printf
(
"%d
\n
"
,
max
-
min
);
return
0
;
}
```
```
data/1.算法初阶/1.蓝桥杯/波动数列/solution.md
浏览文件 @
62f75b25
...
@@ -25,7 +25,17 @@
...
@@ -25,7 +25,17 @@
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int N = 1e3 + 5;
const int mod = 100000007;
int n, s, a, b, up;
ll v;
int dp
[
2
][
N * (N + 1) / 2
]
, now;
int ans;
```
```
### after
### after
```
cpp
```
cpp
...
@@ -34,21 +44,111 @@
...
@@ -34,21 +44,111 @@
## 答案
## 答案
```
cpp
```
cpp
int main()
{
scanf("%d%d%d%d", &n, &s, &a,
&b);
dp
[
now
][
0
]
= 1;
for (int i = 1; i < n; ++i)
{
now = !now;
up = i
*
(i + 1) / 2;
for (int j = 0; j <= up; ++j)
{
dp
[
now
][
j
]
= dp
[
!now
][
j
]
;
if (j >= i)
dp
[
now
][
j
]
= (dp
[
now
][
j
]
+ dp
[
!now
][
j - i
]
) % mod;
}
}
for (int i = 0; i <= up; ++i)
{
v = 1ll
* s - 1ll *
i
* a + 1ll *
(up - i)
*
b;
if (v % n == 0)
ans = (ans + dp
[
now
][
i
]
) % mod;
}
printf("%d
\n
", ans);
return 0;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int main()
{
scanf("%d%d%d%d", &n, &s, &a,
&b);
dp
[
now
][
0
]
= 1;
for (int i = 1; i < n; ++i)
{
now = !now;
up = i
*
(i + 1) / 2;
for (int j = 0; j <= up; ++j)
{
dp
[
now
][
j
]
= dp
[
now
][
j
]
;
if (j >= i)
dp
[
now
][
j
]
= (dp
[
now
][
j
]
+ dp
[
!now
][
j - i
]
) % mod;
}
}
for (int i = 0; i <= up; ++i)
{
v = 1ll
* s - 1ll *
i
* a + 1ll *
(up - i)
*
b;
if (v % n == 0)
ans = (ans + dp
[
now
][
i
]
) % mod;
}
printf("%d
\n
", ans);
return 0;
}
```
```
### B
### B
```
cpp
```
cpp
int main()
{
scanf("%d%d%d%d", &n, &s, &a,
&b);
dp
[
now
][
0
]
= 1;
for (int i = 1; i < n; ++i)
{
up = i
*
(i + 1) / 2;
for (int j = 0; j <= up; ++j)
{
dp
[
now
][
j
]
= dp
[
!now
][
j
]
;
if (j >= i)
dp
[
now
][
j
]
= (dp
[
now
][
j
]
+ dp
[
now
][
j - i
]
) % mod;
}
}
for (int i = 0; i <= up; ++i)
{
v = 1ll
* s - 1ll *
i
* a + 1ll *
(up - i)
*
b;
if (v % n == 0)
ans = (ans + dp
[
now
][
i
]
) % mod;
}
printf("%d
\n
", ans);
return 0;
}
```
```
### C
### C
```
cpp
```
cpp
int main()
{
scanf("%d%d%d%d", &n, &s, &a,
&b);
dp
[
now
][
0
]
= 1;
for (int i = 1; i < n; ++i)
{
up = i
*
(i + 1) / 2;
for (int j = 0; j <= up; ++j)
{
dp
[
now
][
j
]
= dp
[
!now
][
j
]
;
if (j >= i)
dp
[
now
][
j
]
= (dp
[
!now
][
j
]
+ dp
[
!now
][
j - i
]
) % mod;
}
}
for (int i = 0; i <= up; ++i)
{
v = 1ll
* s - 1ll *
i
* a + 1ll *
(up - i)
*
b;
if (v % n == 0)
ans = (ans + dp
[
now
][
i
]
) % mod;
}
printf("%d
\n
", ans);
return 0;
}
```
```
data/1.算法初阶/1.蓝桥杯/测试次数/solution.md
浏览文件 @
62f75b25
...
@@ -16,30 +16,96 @@ x星球有很多高耸入云的高塔,刚好可以用来做耐摔测试。塔
...
@@ -16,30 +16,96 @@ x星球有很多高耸入云的高塔,刚好可以用来做耐摔测试。塔
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <iostream>
using
namespace
std
;
int
num
[
5
][
1010
]
=
{
0
};
```
```
### after
### after
```
cpp
```
cpp
int
main
()
{
cout
<<
dp
(
3
,
1000
)
<<
endl
;
return
0
;
}
```
```
## 答案
## 答案
```
cpp
```
cpp
int
dp
(
int
k
,
int
n
)
{
int
res
=
10000
;
if
(
n
==
0
)
return
0
;
if
(
k
==
1
)
return
n
;
if
(
num
[
k
][
n
])
return
num
[
k
][
n
];
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
res
=
min
(
res
,
max
(
dp
(
k
-
1
,
i
-
1
),
dp
(
k
,
n
-
i
))
+
1
);
}
num
[
k
][
n
]
=
res
;
return
res
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
dp
(
int
k
,
int
n
)
{
int
res
=
10000
;
if
(
n
==
0
)
return
0
;
if
(
k
==
1
)
return
n
;
if
(
num
[
k
][
n
])
return
num
[
k
][
n
];
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
res
=
max
(
res
,
min
(
dp
(
k
-
1
,
i
-
1
),
dp
(
k
,
n
-
1
))
+
1
);
}
num
[
k
][
n
]
=
res
;
return
res
;
}
```
```
### B
### B
```
cpp
```
cpp
int
dp
(
int
k
,
int
n
)
{
int
res
=
10000
;
if
(
n
==
0
)
return
0
;
if
(
k
==
1
)
return
n
;
if
(
num
[
k
][
n
])
return
num
[
k
][
n
];
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
res
=
min
(
res
,
max
(
dp
(
k
+
1
,
i
+
1
),
dp
(
k
,
n
-
i
))
+
1
);
}
num
[
k
][
n
]
=
res
;
return
res
;
}
```
```
### C
### C
```
cpp
```
cpp
int
dp
(
int
k
,
int
n
)
{
int
res
=
10000
;
if
(
n
==
0
)
return
0
;
if
(
k
==
1
)
return
n
;
if
(
num
[
k
][
n
])
return
num
[
k
][
n
];
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
res
=
min
(
res
,
max
(
dp
(
k
-
1
,
i
),
dp
(
k
,
n
-
i
))
+
1
);
}
num
[
k
][
n
]
=
res
;
return
res
;
}
```
```
data/1.算法初阶/1.蓝桥杯/猜字母/solution.md
浏览文件 @
62f75b25
...
@@ -6,7 +6,9 @@
...
@@ -6,7 +6,9 @@
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <iostream>
#include <vector>
using
namespace
std
;
```
```
### after
### after
```
cpp
```
cpp
...
@@ -15,21 +17,89 @@
...
@@ -15,21 +17,89 @@
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
vector
<
char
>
vc1
;
int
i
;
for
(
i
=
0
;
i
<
2014
;
i
++
)
vc1
.
push_back
(
'a'
+
(
i
%
19
));
while
(
vc1
.
size
()
!=
1
)
{
vector
<
char
>
vc2
;
cout
<<
vc1
.
size
()
<<
endl
;
for
(
i
=
1
;
i
<
vc1
.
size
();
i
+=
2
)
vc2
.
push_back
(
vc1
[
i
]);
vc1
.
assign
(
vc2
.
begin
(),
vc2
.
end
());
cout
<<
vc1
.
size
()
<<
endl
;
}
cout
<<
vc1
[
0
]
<<
endl
;
return
0
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
vector
<
char
>
vc1
;
int
i
;
for
(
i
=
0
;
i
<
2014
;
i
++
)
vc1
.
push_back
(
'a'
+
(
i
%
19
));
while
(
vc1
.
size
()
!=
1
)
{
vector
<
char
>
vc2
;
cout
<<
vc1
.
size
()
<<
endl
;
for
(
i
=
0
;
i
<
vc1
.
size
();
i
++
)
vc2
.
push_back
(
vc1
[
i
]);
vc1
.
assign
(
vc2
.
begin
(),
vc2
.
end
());
cout
<<
vc1
.
size
()
<<
endl
;
}
cout
<<
vc1
[
0
]
<<
endl
;
return
0
;
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
vector
<
char
>
vc1
;
int
i
;
for
(
i
=
0
;
i
<
2014
;
i
++
)
vc1
.
push_back
(
'a'
+
(
i
%
19
));
while
(
vc1
.
size
()
!=
1
)
{
vector
<
char
>
vc2
;
cout
<<
vc1
.
size
()
<<
endl
;
for
(
i
=
0
;
i
<
vc1
.
size
();
i
+=
1
)
vc2
.
push_back
(
vc1
[
i
]);
vc1
.
assign
(
vc2
.
begin
(),
vc2
.
end
());
cout
<<
vc1
.
size
()
<<
endl
;
}
cout
<<
vc1
[
0
]
<<
endl
;
return
0
;
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
vector
<
char
>
vc1
;
int
i
;
for
(
i
=
0
;
i
<
2014
;
i
++
)
vc1
.
push_back
(
'a'
+
(
i
%
19
));
while
(
vc1
.
size
()
!=
1
)
{
vector
<
char
>
vc2
;
cout
<<
vc1
.
size
()
<<
endl
;
for
(
i
=
0
;
i
<
vc1
.
size
();
i
+=
2
)
vc2
.
push_back
(
vc1
[
i
]);
vc1
.
assign
(
vc2
.
begin
(),
vc2
.
end
());
cout
<<
vc1
.
size
()
<<
endl
;
}
cout
<<
vc1
[
0
]
<<
endl
;
return
0
;
}
```
```
data/1.算法初阶/1.蓝桥杯/猜年龄/solution.md
浏览文件 @
62f75b25
...
@@ -11,26 +11,38 @@
...
@@ -11,26 +11,38 @@
```
```
### after
### after
```
cpp
```
cpp
#include <iostream>
using
namespace
std
;
int
main
()
{
for
(
int
i
=
11
;
i
<
35
;
i
++
)
{
int
i1
=
i
*
i
*
i
;
int
i2
=
i
*
i1
;
if
((
i1
>=
1000
&&
i1
<
10000
)
&&
(
i2
>=
100000
&&
i2
<
1000000
))
cout
<<
i
<<
" "
<<
i1
<<
" "
<<
i2
<<
endl
;
}
return
0
;
}
```
```
## 答案
## 答案
```
cpp
```
cpp
18
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
19
```
```
### B
### B
```
cpp
```
cpp
20
```
```
### C
### C
```
cpp
```
cpp
21
```
```
data/1.算法初阶/1.蓝桥杯/超级胶水/solution.cpp
浏览文件 @
62f75b25
#include<bits/stdc++.h>
#include
<bits/stdc++.h>
using
namespace
std
;
using
namespace
std
;
const
int
maxn
=
100005
;
const
int
maxn
=
100005
;
int
numv
[
maxn
];
int
numv
[
maxn
];
int
v
[
maxn
];
int
v
[
maxn
];
int
dfs
(
int
idx
)
int
dfs
(
int
idx
)
{
{
if
(
idx
==
0
)
if
(
idx
==
0
)
return
0
;
return
0
;
if
(
idx
==
1
)
if
(
idx
==
1
)
return
v
[
0
]
*
v
[
1
];
return
v
[
0
]
*
v
[
1
];
int
max_
,
a
=
0x3f3f3f
,
b
=
0x3f3f3f3f
,
c
=
0
;
int
max_
,
a
=
0x3f3f3f
,
b
=
0x3f3f3f3f
,
c
=
0
;
if
(
idx
>=
2
)
if
(
idx
>=
2
)
a
=
(
v
[
idx
]
*
v
[
idx
-
1
]
+
dfs
(
idx
-
2
)
+
numv
[
idx
-
2
]
*
(
v
[
idx
]
+
v
[
idx
-
1
]));
//与左边粘
a
=
(
v
[
idx
]
*
v
[
idx
-
1
]
+
dfs
(
idx
-
2
)
+
numv
[
idx
-
2
]
*
(
v
[
idx
]
+
v
[
idx
-
1
]));
//与左边粘
b
=
v
[
idx
]
*
numv
[
idx
-
1
]
+
dfs
(
idx
-
1
);
//与左边不粘
b
=
v
[
idx
]
*
numv
[
idx
-
1
]
+
dfs
(
idx
-
1
);
//与左边不粘
c
=
min
(
a
,
b
);
c
=
min
(
a
,
b
);
return
c
;
return
c
;
}
}
int
main
()
int
main
()
{
{
int
n
;
int
n
;
scanf
(
"%d"
,
&
n
);
scanf
(
"%d"
,
&
n
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
for
(
int
i
=
0
;
i
<
n
;
i
++
)
scanf
(
"%d"
,
&
v
[
i
]);
{
if
(
i
==
0
)
numv
[
i
]
=
v
[
i
];
scanf
(
"%d"
,
&
v
[
i
]);
numv
[
i
]
=
numv
[
i
-
1
]
+
v
[
i
];
if
(
i
==
0
)
}
numv
[
i
]
=
v
[
i
];
numv
[
i
]
=
numv
[
i
-
1
]
+
v
[
i
];
printf
(
"%d"
,
dfs
(
n
-
1
));
}
printf
(
"%d"
,
dfs
(
n
-
1
));
}
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/超级胶水/solution.md
浏览文件 @
62f75b25
...
@@ -21,30 +21,107 @@
...
@@ -21,30 +21,107 @@
## aop
## aop
### before
### before
```
cpp
```
cpp
#include<bits/stdc++.h>
using
namespace
std
;
const
int
maxn
=
100005
;
int
numv
[
maxn
];
int
v
[
maxn
];
```
```
### after
### after
```
cpp
```
cpp
int
main
(){
int
n
;
scanf
(
"%d"
,
&
n
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
scanf
(
"%d"
,
&
v
[
i
]);
if
(
i
==
0
)
numv
[
i
]
=
v
[
i
];
numv
[
i
]
=
numv
[
i
-
1
]
+
v
[
i
];
}
printf
(
"%d"
,
dfs
(
n
-
1
));
}
```
```
## 答案
## 答案
```
cpp
```
cpp
int
dfs
(
int
idx
){
if
(
idx
==
0
)
return
0
;
if
(
idx
==
1
)
return
v
[
0
]
*
v
[
1
];
int
max_
,
a
=
0x3f3f3f
,
b
=
0x3f3f3f3f
,
c
=
0
;
if
(
idx
>=
2
)
a
=
(
v
[
idx
]
*
v
[
idx
-
1
]
+
dfs
(
idx
-
2
)
+
numv
[
idx
-
2
]
*
(
v
[
idx
]
+
v
[
idx
-
1
]));
b
=
v
[
idx
]
*
numv
[
idx
-
1
]
+
dfs
(
idx
-
1
);
c
=
min
(
a
,
b
);
return
c
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
dfs
(
int
idx
)
{
if
(
idx
==
0
)
return
0
;
if
(
idx
==
1
)
return
v
[
0
]
*
v
[
1
];
int
max_
,
a
=
0x3f3f3f
,
b
=
0x3f3f3f3f
,
c
=
0
;
if
(
idx
>=
2
)
a
=
(
v
[
idx
]
*
v
[
idx
]
+
dfs
(
idx
-
2
)
+
numv
[
idx
-
2
]
*
(
v
[
idx
]
+
v
[
idx
-
1
]));
b
=
v
[
idx
]
*
numv
[
idx
]
+
dfs
(
idx
-
1
);
c
=
min
(
a
,
b
);
return
c
;
}
```
```
### B
### B
```
cpp
```
cpp
int
dfs
(
int
idx
)
{
if
(
idx
==
0
)
return
0
;
if
(
idx
==
1
)
return
v
[
0
]
*
v
[
1
];
int
max_
,
a
=
0x3f3f3f
,
b
=
0x3f3f3f3f
,
c
=
0
;
if
(
idx
>=
2
)
a
=
(
v
[
idx
-
2
]
*
v
[
idx
]
+
dfs
(
idx
-
2
)
+
numv
[
idx
-
2
]
*
(
v
[
idx
]
+
v
[
idx
-
1
]));
b
=
v
[
idx
-
2
]
*
numv
[
idx
]
+
dfs
(
idx
-
1
);
c
=
min
(
a
,
b
);
return
c
;
}
```
```
### C
### C
```
cpp
```
cpp
int
dfs
(
int
idx
)
{
if
(
idx
==
0
)
return
0
;
if
(
idx
==
1
)
return
v
[
0
]
*
v
[
1
];
int
max_
,
a
=
0x3f3f3f
,
b
=
0x3f3f3f3f
,
c
=
0
;
if
(
idx
>=
2
)
a
=
(
v
[
idx
]
*
v
[
idx
]
+
dfs
(
idx
-
2
)
+
numv
[
idx
-
2
]
*
(
v
[
idx
]
+
v
[
idx
-
1
]));
b
=
v
[
idx
-
1
]
*
numv
[
idx
]
+
dfs
(
idx
-
1
);
c
=
min
(
a
,
b
);
return
c
;
}
```
```
data/1.算法初阶/1.蓝桥杯/错误票据/solution.md
浏览文件 @
62f75b25
...
@@ -52,7 +52,14 @@
...
@@ -52,7 +52,14 @@
## aop
## aop
### before
### before
```
cpp
```
cpp
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using
namespace
std
;
int
ans
[
10005
];
char
str
[
100001
];
```
```
### after
### after
```
cpp
```
cpp
...
@@ -61,21 +68,145 @@
...
@@ -61,21 +68,145 @@
## 答案
## 答案
```
cpp
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
int
i
,
k
=
0
;
getchar
();
for
(
i
=
0
;
i
<
n
;
i
++
)
{
gets
(
str
);
char
*
p
;
p
=
strtok
(
str
,
" "
);
ans
[
k
++
]
=
atoi
(
p
);
while
(
p
)
{
p
=
strtok
(
NULL
,
" "
);
if
(
p
)
ans
[
k
++
]
=
atoi
(
p
);
}
}
sort
(
ans
,
ans
+
k
);
int
ans1
,
ans2
;
for
(
i
=
0
;
i
<
k
-
1
;
i
++
)
{
if
(
ans
[
i
+
1
]
-
ans
[
i
]
==
2
)
{
ans1
=
ans
[
i
]
+
1
;
}
if
(
ans
[
i
+
1
]
==
ans
[
i
])
ans2
=
ans
[
i
];
}
cout
<<
ans1
<<
" "
<<
ans2
;
}
```
```
## 选项
## 选项
### A
### A
```
cpp
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
int
i
,
k
=
0
;
getchar
();
for
(
i
=
0
;
i
<
n
;
i
++
)
{
gets
(
str
);
char
*
p
;
p
=
strtok
(
str
,
" "
);
ans
[
k
++
]
=
atoi
(
p
);
while
(
p
)
{
p
=
strtok
(
NULL
,
" "
);
if
(
p
)
ans
[
k
]
=
atoi
(
p
);
}
}
sort
(
ans
,
ans
+
k
);
int
ans1
,
ans2
;
for
(
i
=
0
;
i
<
k
-
1
;
i
++
)
{
if
(
ans
[
i
+
1
]
-
ans
[
i
]
==
2
)
{
ans1
=
ans
[
i
]
+
1
;
}
if
(
ans
[
i
+
1
]
==
ans
[
i
])
ans2
=
ans
[
i
];
}
cout
<<
ans1
<<
" "
<<
ans2
;
}
```
```
### B
### B
```
cpp
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
int
i
,
k
=
0
;
getchar
();
for
(
i
=
0
;
i
<
n
;
i
++
)
{
gets
(
str
);
char
*
p
;
p
=
strtok
(
str
,
" "
);
ans
[
k
++
]
=
atoi
(
p
);
while
(
p
)
{
p
=
strtok
(
NULL
,
" "
);
if
(
p
)
ans
[
k
++
]
=
atoi
(
p
);
}
}
sort
(
ans
,
ans
+
k
);
int
ans1
,
ans2
;
for
(
i
=
0
;
i
<
k
-
1
;
i
++
)
{
if
(
ans
[
i
+
1
]
-
ans
[
i
]
==
2
)
{
ans1
=
ans
[
i
+
1
];
}
if
(
ans
[
i
+
1
]
==
ans
[
i
])
ans2
=
ans
[
i
];
}
cout
<<
ans1
<<
" "
<<
ans2
;
}
```
```
### C
### C
```
cpp
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
int
i
,
k
=
0
;
getchar
();
for
(
i
=
0
;
i
<
n
;
i
++
)
{
gets
(
str
);
char
*
p
;
p
=
strtok
(
str
,
" "
);
ans
[
k
++
]
=
atoi
(
p
);
while
(
p
)
{
p
=
strtok
(
NULL
,
" "
);
if
(
p
)
ans
[
k
++
]
=
atoi
(
p
);
}
}
sort
(
ans
,
ans
+
k
);
int
ans1
,
ans2
;
for
(
i
=
0
;
i
<
k
-
1
;
i
++
)
{
if
(
ans
[
i
+
1
]
-
ans
[
i
]
==
1
)
{
ans1
=
ans
[
i
]
+
1
;
}
if
(
ans
[
i
+
1
]
==
ans
[
i
])
ans2
=
ans
[
i
];
}
cout
<<
ans1
<<
" "
<<
ans2
;
}
```
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录