Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_algorithm
提交
cba017e9
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看板
提交
cba017e9
编写于
10月 28, 2021
作者:
每日一练社区
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update exercises
上级
4c49dc90
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
432 addition
and
11 deletion
+432
-11
data/1.算法初阶/1.蓝桥杯/第39级台阶/solution.md
data/1.算法初阶/1.蓝桥杯/第39级台阶/solution.md
+65
-5
data/1.算法初阶/1.蓝桥杯/第几个幸运数/solution.md
data/1.算法初阶/1.蓝桥杯/第几个幸运数/solution.md
+125
-3
data/1.算法初阶/1.蓝桥杯/第几天/solution.cpp
data/1.算法初阶/1.蓝桥杯/第几天/solution.cpp
+2
-2
data/1.算法初阶/1.蓝桥杯/第几天/solution.md
data/1.算法初阶/1.蓝桥杯/第几天/solution.md
+107
-1
data/1.算法初阶/1.蓝桥杯/递增三元组/solution.md
data/1.算法初阶/1.蓝桥杯/递增三元组/solution.md
+133
-0
未找到文件。
data/1.算法初阶/1.蓝桥杯/第39级台阶/solution.md
浏览文件 @
cba017e9
...
...
@@ -11,7 +11,11 @@
## aop
### before
```
cpp
#include <iostream>
#define LEFT 0
#define RIGHT 1
using
namespace
std
;
int
stage
[
40
][
2
];
```
### after
```
cpp
...
...
@@ -20,21 +24,77 @@
## 答案
```
cpp
int
main
()
{
int
i
;
stage
[
1
][
LEFT
]
=
1
;
stage
[
1
][
RIGHT
]
=
0
;
stage
[
2
][
LEFT
]
=
1
;
stage
[
2
][
RIGHT
]
=
1
;
for
(
i
=
3
;
i
<=
39
;
i
++
)
{
stage
[
i
][
LEFT
]
=
stage
[
i
-
1
][
RIGHT
]
+
stage
[
i
-
2
][
RIGHT
];
stage
[
i
][
RIGHT
]
=
stage
[
i
-
1
][
LEFT
]
+
stage
[
i
-
2
][
LEFT
];
}
cout
<<
stage
[
39
][
RIGHT
]
<<
endl
;
return
0
;
}
```
## 选项
### A
```
cpp
int
main
()
{
int
i
;
stage
[
1
][
LEFT
]
=
1
;
stage
[
1
][
RIGHT
]
=
0
;
stage
[
2
][
LEFT
]
=
1
;
stage
[
2
][
RIGHT
]
=
1
;
for
(
i
=
3
;
i
<=
39
;
i
++
)
{
stage
[
i
][
LEFT
]
=
stage
[
i
-
1
][
RIGHT
]
+
stage
[
i
-
2
][
RIGHT
];
stage
[
i
][
RIGHT
]
=
stage
[
i
-
1
][
LEFT
]
+
stage
[
i
-
2
][
LEFT
];
}
cout
<<
stage
[
39
][
LEFT
]
<<
endl
;
return
0
;
}
```
### B
```
cpp
int
main
()
{
int
i
;
stage
[
1
][
LEFT
]
=
1
;
stage
[
1
][
RIGHT
]
=
0
;
stage
[
2
][
LEFT
]
=
1
;
stage
[
2
][
RIGHT
]
=
1
;
for
(
i
=
3
;
i
<=
39
;
i
++
)
{
stage
[
i
][
LEFT
]
=
stage
[
i
+
1
][
RIGHT
]
+
stage
[
i
-
1
][
RIGHT
];
stage
[
i
][
RIGHT
]
=
stage
[
i
+
1
][
LEFT
]
+
stage
[
i
-
1
][
LEFT
];
}
cout
<<
stage
[
39
][
RIGHT
]
<<
endl
;
return
0
;
}
```
### C
```
cpp
int
main
()
{
int
i
;
stage
[
1
][
LEFT
]
=
1
;
stage
[
1
][
RIGHT
]
=
0
;
stage
[
2
][
LEFT
]
=
1
;
stage
[
2
][
RIGHT
]
=
1
;
for
(
i
=
3
;
i
<=
39
;
i
++
)
{
stage
[
i
][
LEFT
]
=
stage
[
i
+
1
][
RIGHT
]
+
stage
[
i
-
1
][
RIGHT
];
stage
[
i
][
RIGHT
]
=
stage
[
i
+
1
][
LEFT
]
+
stage
[
i
-
1
][
LEFT
];
}
cout
<<
stage
[
39
][
LEFT
]
<<
endl
;
return
0
;
}
```
data/1.算法初阶/1.蓝桥杯/第几个幸运数/solution.md
浏览文件 @
cba017e9
...
...
@@ -16,7 +16,11 @@ x星的国王有个怪癖,他只喜欢数字3,5和7。
## aop
### before
```
cpp
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
using
namespace
std
;
```
### after
```
cpp
...
...
@@ -25,21 +29,139 @@ x星的国王有个怪癖,他只喜欢数字3,5和7。
## 答案
```
cpp
int
main
()
{
set
<
long
long
>
st
;
priority_queue
<
long
long
,
vector
<
long
long
>
,
greater
<
long
long
>>
pq
;
const
int
ok
[
3
]
=
{
3
,
5
,
7
};
st
.
insert
(
1
);
pq
.
push
(
1
);
int
times
=
0
;
while
(
true
)
{
long
long
lucky
=
pq
.
top
();
pq
.
pop
();
if
(
lucky
==
59084709587505
)
{
//49
cout
<<
times
<<
endl
;
return
0
;
}
times
++
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
long
long
b
=
lucky
*
ok
[
i
];
if
(
!
st
.
count
(
b
))
{
st
.
insert
(
b
);
pq
.
push
(
b
);
}
}
}
return
0
;
}
```
## 选项
### A
```
cpp
int
main
()
{
set
<
long
long
>
st
;
priority_queue
<
long
long
,
vector
<
long
long
>
,
greater
<
long
long
>>
pq
;
const
int
ok
[
3
]
=
{
3
,
5
,
7
};
st
.
insert
(
1
);
pq
.
push
(
1
);
int
times
=
0
;
while
(
true
)
{
long
long
lucky
=
pq
.
top
();
pq
.
pop
();
if
(
lucky
==
59084709587505
)
{
//49
cout
<<
times
<<
endl
;
return
0
;
}
times
++
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
long
long
b
=
lucky
*
ok
[
i
+
1
];
if
(
!
st
.
count
(
b
))
{
st
.
insert
(
b
);
pq
.
push
(
b
);
}
}
}
return
0
;
}
```
### B
```
cpp
int
main
()
{
set
<
long
long
>
st
;
priority_queue
<
long
long
,
vector
<
long
long
>
,
greater
<
long
long
>>
pq
;
const
int
ok
[
3
]
=
{
3
,
5
,
7
};
st
.
insert
(
1
);
pq
.
push
(
1
);
int
times
=
0
;
while
(
true
)
{
long
long
lucky
=
pq
.
top
();
pq
.
pop
();
if
(
lucky
==
59084709587505
)
{
//49
cout
<<
times
<<
endl
;
return
0
;
}
times
++
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
long
long
b
=
lucky
*
ok
[
i
]
+
1
;
if
(
!
st
.
count
(
b
))
{
st
.
insert
(
b
);
pq
.
push
(
b
);
}
}
}
return
0
;
}
```
### C
```
cpp
int
main
()
{
set
<
long
long
>
st
;
priority_queue
<
long
long
,
vector
<
long
long
>
,
greater
<
long
long
>>
pq
;
const
int
ok
[
3
]
=
{
3
,
5
,
7
};
st
.
insert
(
1
);
pq
.
push
(
1
);
int
times
=
0
;
while
(
true
)
{
long
long
lucky
=
pq
.
top
();
pq
.
pop
();
if
(
lucky
==
59084709587505
)
{
//49
cout
<<
times
<<
endl
;
return
0
;
}
times
++
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
long
long
b
=
lucky
+
ok
[
i
];
if
(
!
st
.
count
(
b
))
{
st
.
insert
(
b
);
pq
.
push
(
b
);
}
}
}
return
0
;
}
```
data/1.算法初阶/1.蓝桥杯/第几天/solution.cpp
浏览文件 @
cba017e9
...
...
@@ -13,7 +13,7 @@ int main()
if
(
is_leap
(
y
))
//判断闰年
{
for
(
int
i
=
0
;
i
<
(
m
-
1
)
;
i
++
)
//记录1-(m-1)月天数
for
(
int
i
=
0
;
i
<
m
;
i
++
)
//记录1-(m-1)月天数
{
ans
+=
L_m_d
[
i
];
}
...
...
@@ -21,7 +21,7 @@ int main()
}
else
{
for
(
int
i
=
0
;
i
<
(
m
-
1
)
;
i
++
)
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
ans
+=
nonL_m_d
[
i
];
}
...
...
data/1.算法初阶/1.蓝桥杯/第几天/solution.md
浏览文件 @
cba017e9
...
...
@@ -23,7 +23,12 @@ y m d
## aop
### before
```
cpp
#include <iostream>
using
namespace
std
;
bool
is_leap
(
int
year
)
{
return
(
year
%
4
==
0
&&
year
%
100
!=
0
)
||
year
%
400
==
0
;
}
```
### after
```
cpp
...
...
@@ -32,21 +37,122 @@ y m d
## 答案
```
cpp
int
main
()
{
int
y
,
m
,
d
,
ans
=
0
;
cin
>>
y
>>
m
>>
d
;
int
L_m_d
[
12
]
=
{
31
,
29
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
int
nonL_m_d
[
12
]
=
{
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
if
(
is_leap
(
y
))
//判断闰年
{
for
(
int
i
=
0
;
i
<
(
m
-
1
);
i
++
)
//记录1-(m-1)月天数
{
ans
+=
L_m_d
[
i
];
}
ans
+=
d
;
}
else
{
for
(
int
i
=
0
;
i
<
(
m
-
1
);
i
++
)
{
ans
+=
nonL_m_d
[
i
];
}
ans
+=
d
;
}
cout
<<
ans
<<
endl
;
return
0
;
}
```
## 选项
### A
```
cpp
int
main
()
{
int
y
,
m
,
d
,
ans
=
0
;
cin
>>
y
>>
m
>>
d
;
int
L_m_d
[
12
]
=
{
31
,
29
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
int
nonL_m_d
[
12
]
=
{
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
if
(
is_leap
(
y
))
//判断闰年
{
for
(
int
i
=
0
;
i
<
m
;
i
++
)
//记录1-(m-1)月天数
{
ans
+=
L_m_d
[
i
];
}
ans
+=
d
;
}
else
{
for
(
int
i
=
0
;
i
<
(
m
-
1
);
i
++
)
{
ans
+=
nonL_m_d
[
i
];
}
ans
+=
d
;
}
cout
<<
ans
<<
endl
;
return
0
;
}
```
### B
```
cpp
int
main
()
{
int
y
,
m
,
d
,
ans
=
0
;
cin
>>
y
>>
m
>>
d
;
int
L_m_d
[
12
]
=
{
31
,
29
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
int
nonL_m_d
[
12
]
=
{
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
if
(
is_leap
(
y
))
//判断闰年
{
for
(
int
i
=
0
;
i
<
(
m
-
1
);
i
++
)
//记录1-(m-1)月天数
{
ans
+=
L_m_d
[
i
];
}
ans
+=
d
;
}
else
{
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
ans
+=
nonL_m_d
[
i
];
}
ans
+=
d
;
}
cout
<<
ans
<<
endl
;
return
0
;
}
```
### C
```
cpp
int
main
()
{
int
y
,
m
,
d
,
ans
=
0
;
cin
>>
y
>>
m
>>
d
;
int
L_m_d
[
12
]
=
{
31
,
29
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
int
nonL_m_d
[
12
]
=
{
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
};
if
(
is_leap
(
y
))
//判断闰年
{
for
(
int
i
=
0
;
i
<
m
;
i
++
)
//记录1-(m-1)月天数
{
ans
+=
L_m_d
[
i
];
}
ans
+=
d
;
}
else
{
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
ans
+=
nonL_m_d
[
i
];
}
ans
+=
d
;
}
cout
<<
ans
<<
endl
;
return
0
;
}
```
data/1.算法初阶/1.蓝桥杯/递增三元组/solution.md
浏览文件 @
cba017e9
...
...
@@ -35,6 +35,15 @@ C = [C1, C2, ... CN],
## aop
### before
```
cpp
#include <iostream>
#include <cstring>
using
namespace
std
;
typedef
long
long
LL
;
const
int
N
=
1e5
+
10
;
int
a
[
N
],
b
[
N
],
c
[
N
],
sa
[
N
],
sc
[
N
],
s
[
N
];
```
### after
...
...
@@ -44,21 +53,145 @@ C = [C1, C2, ... CN],
## 答案
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
a
[
i
],
a
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
b
[
i
],
b
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
c
[
i
],
c
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
s
[
a
[
i
]]
++
;
for
(
int
i
=
1
;
i
<
N
;
i
++
)
s
[
i
]
+=
s
[
i
-
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sa
[
i
]
=
s
[
b
[
i
]
-
1
];
memset
(
s
,
0
,
sizeof
s
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
s
[
c
[
i
]]
++
;
for
(
int
i
=
1
;
i
<
N
;
i
++
)
s
[
i
]
+=
s
[
i
-
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sc
[
i
]
=
s
[
N
-
1
]
-
s
[
b
[
i
]];
LL
res
=
0
;
for
(
int
i
=
0
;
i
<=
n
;
i
++
)
res
+=
(
LL
)
sa
[
i
]
*
sc
[
i
];
cout
<<
res
;
}
```
## 选项
### A
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
a
[
i
],
a
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
b
[
i
],
b
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
c
[
i
],
c
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
s
[
a
[
i
]]
++
;
for
(
int
i
=
1
;
i
<
N
;
i
++
)
s
[
i
]
+=
s
[
i
-
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sa
[
i
]
=
s
[
b
[
i
]
-
1
];
memset
(
s
,
0
,
sizeof
s
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
s
[
c
[
i
]]
++
;
for
(
int
i
=
1
;
i
<
N
;
i
++
)
s
[
i
]
+=
s
[
i
-
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sc
[
i
]
=
s
[
N
]
-
s
[
b
[
i
]];
LL
res
=
0
;
for
(
int
i
=
0
;
i
<=
n
;
i
++
)
res
+=
(
LL
)
sa
[
i
]
*
sc
[
i
];
cout
<<
res
;
}
```
### B
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
a
[
i
],
a
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
b
[
i
],
b
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
c
[
i
],
c
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
s
[
a
[
i
]]
++
;
for
(
int
i
=
1
;
i
<
N
;
i
++
)
s
[
i
]
+=
s
[
i
-
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sa
[
i
]
=
s
[
b
[
i
]
-
1
];
memset
(
s
,
0
,
sizeof
s
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
s
[
c
[
i
]]
++
;
for
(
int
i
=
1
;
i
<
N
;
i
++
)
s
[
i
]
=
s
[
i
-
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sc
[
i
]
=
s
[
N
-
1
]
-
s
[
b
[
i
]];
LL
res
=
0
;
for
(
int
i
=
0
;
i
<=
n
;
i
++
)
res
+=
(
LL
)
sa
[
i
]
*
sc
[
i
];
cout
<<
res
;
}
```
### C
```
cpp
int
main
()
{
int
n
;
cin
>>
n
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
a
[
i
],
a
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
b
[
i
],
b
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
cin
>>
c
[
i
],
c
[
i
]
++
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
s
[
a
[
i
]]
++
;
for
(
int
i
=
1
;
i
<
N
;
i
++
)
s
[
i
]
+=
s
[
i
-
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sa
[
i
]
=
s
[
b
[
i
]
-
1
];
memset
(
s
,
0
,
sizeof
s
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
s
[
c
[
i
]]
++
;
for
(
int
i
=
1
;
i
<
N
;
i
++
)
s
[
i
]
=
s
[
i
-
1
];
for
(
int
i
=
0
;
i
<
n
;
i
++
)
sc
[
i
]
=
s
[
N
-
1
]
-
s
[
b
[
i
]
-
1
];
LL
res
=
0
;
for
(
int
i
=
0
;
i
<=
n
;
i
++
)
res
+=
(
LL
)
sa
[
i
]
*
sc
[
i
];
cout
<<
res
;
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录