Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_algorithm
提交
f1d08c9c
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看板
提交
f1d08c9c
编写于
10月 15, 2021
作者:
每日一练社区
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update algorithm exercises
上级
e434a100
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
526 addition
and
376 deletion
+526
-376
data/1.算法初阶/1.蓝桥杯/7段码/solution.cpp
data/1.算法初阶/1.蓝桥杯/7段码/solution.cpp
+3
-5
data/1.算法初阶/1.蓝桥杯/9数算式/solution.cpp
data/1.算法初阶/1.蓝桥杯/9数算式/solution.cpp
+32
-32
data/1.算法初阶/1.蓝桥杯/不同子串/solution.cpp
data/1.算法初阶/1.蓝桥杯/不同子串/solution.cpp
+6
-5
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.cpp
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.cpp
+15
-11
data/1.算法初阶/1.蓝桥杯/乘积最大/solution.cpp
data/1.算法初阶/1.蓝桥杯/乘积最大/solution.cpp
+27
-22
data/1.算法初阶/1.蓝桥杯/倍数问题/solution.cpp
data/1.算法初阶/1.蓝桥杯/倍数问题/solution.cpp
+35
-29
data/1.算法初阶/1.蓝桥杯/八次求和/solution.java
data/1.算法初阶/1.蓝桥杯/八次求和/solution.java
+1
-1
data/1.算法初阶/1.蓝桥杯/凑算式/solution.cpp
data/1.算法初阶/1.蓝桥杯/凑算式/solution.cpp
+9
-9
data/1.算法初阶/1.蓝桥杯/大数乘法/solution.cpp
data/1.算法初阶/1.蓝桥杯/大数乘法/solution.cpp
+31
-31
data/1.算法初阶/1.蓝桥杯/大臣的旅费/solution.cpp
data/1.算法初阶/1.蓝桥杯/大臣的旅费/solution.cpp
+46
-39
data/1.算法初阶/1.蓝桥杯/成绩分析/solution.cpp
data/1.算法初阶/1.蓝桥杯/成绩分析/solution.cpp
+15
-12
data/1.算法初阶/1.蓝桥杯/成绩统计/solution.cpp
data/1.算法初阶/1.蓝桥杯/成绩统计/solution.cpp
+22
-14
data/1.算法初阶/1.蓝桥杯/打印图形/solution.cpp
data/1.算法初阶/1.蓝桥杯/打印图形/solution.cpp
+22
-19
data/1.算法初阶/1.蓝桥杯/承压计算/solution.cpp
data/1.算法初阶/1.蓝桥杯/承压计算/solution.cpp
+18
-18
data/1.算法初阶/1.蓝桥杯/抽签/solution.cpp
data/1.算法初阶/1.蓝桥杯/抽签/solution.cpp
+16
-15
data/1.算法初阶/1.蓝桥杯/搭积木/solution.cpp
data/1.算法初阶/1.蓝桥杯/搭积木/solution.cpp
+38
-25
data/1.算法初阶/1.蓝桥杯/次数差/solution.cpp
data/1.算法初阶/1.蓝桥杯/次数差/solution.cpp
+3
-3
data/1.算法初阶/1.蓝桥杯/比酒量/solution.cpp
data/1.算法初阶/1.蓝桥杯/比酒量/solution.cpp
+29
-17
data/1.算法初阶/1.蓝桥杯/波动数列/solution.cpp
data/1.算法初阶/1.蓝桥杯/波动数列/solution.cpp
+23
-20
data/1.算法初阶/1.蓝桥杯/测试次数/solution.cpp
data/1.算法初阶/1.蓝桥杯/测试次数/solution.cpp
+11
-10
data/1.算法初阶/1.蓝桥杯/猜字母/solution.cpp
data/1.算法初阶/1.蓝桥杯/猜字母/solution.cpp
+13
-12
data/1.算法初阶/1.蓝桥杯/猜年龄/solution.cpp
data/1.算法初阶/1.蓝桥杯/猜年龄/solution.cpp
+6
-4
data/1.算法初阶/1.蓝桥杯/错误票据/solution.cpp
data/1.算法初阶/1.蓝桥杯/错误票据/solution.cpp
+23
-23
data/1.算法初阶/1.蓝桥杯/马虎的算式/desc.md
data/1.算法初阶/1.蓝桥杯/马虎的算式/desc.md
+19
-0
data/1.算法初阶/1.蓝桥杯/马虎的算式/solution.cpp
data/1.算法初阶/1.蓝桥杯/马虎的算式/solution.cpp
+33
-0
data/1.算法初阶/1.蓝桥杯/马虎的算式/solution.java
data/1.算法初阶/1.蓝桥杯/马虎的算式/solution.java
+30
-0
未找到文件。
data/1.算法初阶/1.蓝桥杯/7段码/solution.cpp
浏览文件 @
f1d08c9c
#include<iostream>
#include
<iostream>
using
namespace
std
;
int
use
[
10
];
int
ans
,
e
[
10
][
10
],
father
[
10
];
...
...
@@ -15,8 +15,7 @@ void init()
e
[
6
][
1
]
=
e
[
6
][
5
]
=
e
[
6
][
7
]
=
1
;
}
int
find
(
int
a
)
//并查集
int
find
(
int
a
)
//并查集
{
if
(
father
[
a
]
==
a
)
return
a
;
...
...
@@ -24,9 +23,8 @@ int find(int a)//并查集
return
father
[
a
];
}
//深度遍历
void
dfs
(
int
d
)
void
dfs
(
int
d
)
{
if
(
d
>
7
)
{
...
...
data/1.算法初阶/1.蓝桥杯/9数算式/solution.cpp
浏览文件 @
f1d08c9c
#include<bits/stdc++.h>
#include
<bits/stdc++.h>
using
namespace
std
;
int
bei
[
10
];
//备用
map
<
long
long
,
int
>
mp
;
int
bei
[
10
];
//备用
map
<
long
long
,
int
>
mp
;
int
main
()
{
int
a
[
9
]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
};
int
res
=
0
;
int
a
[
9
]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
};
int
res
=
0
;
do
{
for
(
int
i
=
1
;
i
<
9
;
i
++
)
for
(
int
i
=
1
;
i
<
9
;
i
++
)
{
memset
(
bei
,
0
,
sizeof
(
bei
));
//分配空间
long
long
int
ans
,
left
=
0
,
right
=
0
,
t
=
0
,
x
=
0
,
y
=
0
;
for
(
int
j
=
0
;
j
<=
i
;
j
++
)
memset
(
bei
,
0
,
sizeof
(
bei
));
//分配空间
long
long
int
ans
,
left
=
0
,
right
=
0
,
t
=
0
,
x
=
0
,
y
=
0
;
for
(
int
j
=
0
;
j
<=
i
;
j
++
)
{
left
=
left
*
10
+
a
[
j
];
left
=
left
*
10
+
a
[
j
];
}
x
=
left
;
x
=
x
*
10
;
for
(
int
k
=
i
+
1
;
k
<
9
;
k
++
)
x
=
left
;
x
=
x
*
10
;
for
(
int
k
=
i
+
1
;
k
<
9
;
k
++
)
{
right
=
right
*
10
+
a
[
k
];
x
=
x
*
10
+
a
[
k
];
right
=
right
*
10
+
a
[
k
];
x
=
x
*
10
+
a
[
k
];
}
y
=
right
;
y
=
y
*
10
;
for
(
int
j
=
0
;
j
<=
i
;
j
++
)
y
=
y
*
10
+
a
[
j
];
ans
=
left
*
right
;
long
long
int
ff
=
ans
;
while
(
ans
>
0
)
y
=
right
;
y
=
y
*
10
;
for
(
int
j
=
0
;
j
<=
i
;
j
++
)
y
=
y
*
10
+
a
[
j
];
ans
=
left
*
right
;
long
long
int
ff
=
ans
;
while
(
ans
>
0
)
{
int
x
=
ans
%
10
;
ans
=
ans
/
10
;
if
(
bei
[
x
]
==
0
&&
x
!=
0
)
int
x
=
ans
%
10
;
ans
=
ans
/
10
;
if
(
bei
[
x
]
==
0
&&
x
!=
0
)
{
bei
[
x
]
=
1
;
bei
[
x
]
=
1
;
t
++
;
}
}
if
(
t
==
9
&&
mp
.
count
(
x
)
==
0
&&
mp
.
count
(
y
)
==
0
)
if
(
t
==
9
&&
mp
.
count
(
x
)
==
0
&&
mp
.
count
(
y
)
==
0
)
{
res
++
;
mp
[
x
]
=
1
;
mp
[
y
]
=
1
;
mp
[
x
]
=
1
;
mp
[
y
]
=
1
;
}
}
}
while
(
next_permutation
(
a
,
a
+
9
));
//全排列
cout
<<
res
<<
endl
;
}
while
(
next_permutation
(
a
,
a
+
9
));
//全排列
cout
<<
res
<<
endl
;
return
0
;
}
data/1.算法初阶/1.蓝桥杯/不同子串/solution.cpp
浏览文件 @
f1d08c9c
#include <bits/stdc++.h>
using
namespace
std
;
int
main
(){
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
++
)
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
;
...
...
data/1.算法初阶/1.蓝桥杯/乘积尾零/solution.cpp
浏览文件 @
f1d08c9c
#include<iostream>
#include
<iostream>
using
namespace
std
;
int
main
(){
int
count2
=
0
,
count5
=
0
;
int
main
()
{
int
count2
=
0
,
count5
=
0
;
int
num
;
for
(
int
i
=
0
;
i
<
100
;
i
++
){
cin
>>
num
;
while
(
num
%
5
==
0
){
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
cin
>>
num
;
while
(
num
%
5
==
0
)
{
count5
++
;
num
/=
5
;
num
/=
5
;
}
while
(
num
%
2
==
0
){
while
(
num
%
2
==
0
)
{
count2
++
;
num
/=
2
;
num
/=
2
;
}
}
int
ans
=
count2
<
count5
?
count2
:
count5
;
cout
<<
ans
;
int
ans
=
count2
<
count5
?
count2
:
count5
;
cout
<<
ans
;
return
0
;
}
data/1.算法初阶/1.蓝桥杯/乘积最大/solution.cpp
浏览文件 @
f1d08c9c
#include<iostream>
#include
<iostream>
#include <vector>
#include<algorithm>
#include
<algorithm>
using
namespace
std
;
int
main
(){
int
n
,
k
;
int
main
()
{
int
n
,
k
;
long
long
ans
;
cin
>>
n
>>
k
;
vector
<
long
long
>
num
;
for
(
int
i
=
0
;
i
<
n
;
i
++
){
cin
>>
n
>>
k
;
vector
<
long
long
>
num
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
int
temp
;
cin
>>
temp
;
cin
>>
temp
;
num
.
push_back
(
temp
);
}
sort
(
num
.
begin
(),
num
.
end
());
if
(
k
%
2
!=
0
){
ans
=
num
.
back
();
k
=
k
-
1
;
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
);
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
;
else
{
ans
=
ans
*
num
.
at
(
num
.
size
()
-
1
)
*
num
.
at
(
num
.
size
()
-
2
)
%
1000000009
;
num
.
pop_back
();
num
.
pop_back
();
}
k
-=
2
;
k
-=
2
;
}
cout
<<
ans
;
cout
<<
ans
;
return
0
;
}
data/1.算法初阶/1.蓝桥杯/倍数问题/solution.cpp
浏览文件 @
f1d08c9c
#include<bits/stdc++.h>
#include
<string>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
#include<algorithm>
#include
<bits/stdc++.h>
#include
<string>
#include
<queue>
#include
<set>
#include
<cstring>
#include
<cmath>
#include
<algorithm>
#define MAX 1000000000
using
namespace
std
;
int
n
,
k
,
a
[
100010
];
int
n
,
k
,
a
[
100010
];
int
b
[
4
];
int
flag
=
0
;
void
dfs
(
int
a
[],
int
n
,
int
s
){
if
(
flag
==
1
)
return
;
if
(
s
==
4
){
int
sum
=
b
[
1
]
+
b
[
2
]
+
b
[
3
];
if
(
sum
%
k
==
0
){
flag
=
1
;
cout
<<
sum
<<
endl
;
int
flag
=
0
;
void
dfs
(
int
a
[],
int
n
,
int
s
)
{
if
(
flag
==
1
)
return
;
if
(
s
==
4
)
{
int
sum
=
b
[
1
]
+
b
[
2
]
+
b
[
3
];
if
(
sum
%
k
==
0
)
{
flag
=
1
;
cout
<<
sum
<<
endl
;
}
return
;
}
for
(
int
i
=
1
;
i
<=
n
;
i
++
){
if
(
a
[
i
]
<
a
[
s
-
1
]){
b
[
s
]
=
a
[
i
];
dfs
(
a
,
n
,
s
+
1
);
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
if
(
a
[
i
]
<
a
[
s
-
1
])
{
b
[
s
]
=
a
[
i
];
dfs
(
a
,
n
,
s
+
1
);
}
}
}
int
main
(){
cin
>>
n
>>
k
;
a
[
0
]
=
MAX
;
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
cin
>>
a
[
i
];
sort
(
a
+
1
,
a
+
n
+
1
);
reverse
(
a
+
1
,
a
+
n
+
1
);
dfs
(
a
,
n
,
1
);
int
main
()
{
cin
>>
n
>>
k
;
a
[
0
]
=
MAX
;
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
cin
>>
a
[
i
];
sort
(
a
+
1
,
a
+
n
+
1
);
reverse
(
a
+
1
,
a
+
n
+
1
);
dfs
(
a
,
n
,
1
);
return
0
;
}
data/1.算法初阶/1.蓝桥杯/八次求和/solution.java
浏览文件 @
f1d08c9c
import
java.util.Scanner
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
int
mod
=
123456789
;
Scanner
s
=
new
Scanner
(
System
.
in
);
int
n
=
s
.
nextInt
();
long
result
=
0
;
...
...
data/1.算法初阶/1.蓝桥杯/凑算式/solution.cpp
浏览文件 @
f1d08c9c
#include<stdio.h>
#include<stdbool.h>
#include
<stdio.h>
#include
<stdbool.h>
int
ans
=
0
;
int
nums
[
10
];
...
...
@@ -8,24 +8,24 @@ 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
)
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
(
"%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
++
;
}
}
void
dfs
(
int
index
)
{
if
(
index
>=
9
)
if
(
index
>=
9
)
{
judge
();
return
;
return
;
}
int
i
;
for
(
i
=
1
;
i
<
10
;
i
++
)
for
(
i
=
1
;
i
<
10
;
i
++
)
{
if
(
visited
[
i
]
==
false
)
if
(
visited
[
i
]
==
false
)
{
visited
[
i
]
=
true
;
nums
[
index
]
=
i
;
...
...
@@ -37,6 +37,6 @@ void dfs(int index)
int
main
()
{
dfs
(
0
);
printf
(
"%d
\n
"
,
ans
);
printf
(
"%d
\n
"
,
ans
);
return
0
;
}
data/1.算法初阶/1.蓝桥杯/大数乘法/solution.cpp
浏览文件 @
f1d08c9c
#
include <stdio.h>
#include <stdio.h>
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
;
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
;
}
int
main
(
int
argc
,
char
*
argv
[])
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
;
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
;
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/大臣的旅费/solution.cpp
浏览文件 @
f1d08c9c
#include<bits/stdc++.h>
#include
<bits/stdc++.h>
using
namespace
std
;
#define mem(a,
b) memset(a,b,sizeof(a))
//不能mem(double)
#define mem(a,
b) memset(a, b, sizeof(a))
//不能mem(double)
#define ll long long
const
double
eps
=
3e-8
;
const
int
mod
=
10
;
const
int
maxn
=
10005
;
//最好数量范围大一点;1e4+5 && long long
vector
<
int
>
ed
[
maxn
];
//存储每个点的邻接点
ll
edge
[
maxn
][
maxn
];
//存储每个边值
ll
dis
[
maxn
];
//存储bfs中从node点开始的路径长
ll
sum
=
0
;
int
bfs
(
int
node
){
mem
(
dis
,
-
1
);
queue
<
int
>
que
;
const
double
eps
=
3e-8
;
const
int
mod
=
10
;
const
int
maxn
=
10005
;
//最好数量范围大一点;1e4+5 && long long
vector
<
int
>
ed
[
maxn
];
//存储每个点的邻接点
ll
edge
[
maxn
][
maxn
];
//存储每个边值
ll
dis
[
maxn
];
//存储bfs中从node点开始的路径长
ll
sum
=
0
;
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
();
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
];
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
);
}
...
...
@@ -32,25 +37,27 @@ int bfs(int node){
}
return
ans
;
}
int
main
(){
freopen
(
"in4.txt"
,
"r"
,
stdin
);
int
n
,
a
,
b
;
int
main
()
{
freopen
(
"in4.txt"
,
"r"
,
stdin
);
int
n
,
a
,
b
;
ll
c
;
scanf
(
"%d"
,
&
n
);
for
(
int
i
=
1
;
i
<
n
;
i
++
){
scanf
(
"%d%d%lld"
,
&
a
,
&
b
,
&
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
;
edge
[
a
][
b
]
=
c
;
edge
[
b
][
a
]
=
c
;
}
int
starta
=
1
;
int
endnode
,
startnode
;
sum
=
0
;
endnode
=
bfs
(
starta
);
sum
=
0
;
startnode
=
bfs
(
endnode
);
int
starta
=
1
;
int
endnode
,
startnode
;
sum
=
0
;
endnode
=
bfs
(
starta
);
sum
=
0
;
startnode
=
bfs
(
endnode
);
///cout<<endnode<<" "<<startnode<<" "<<sum<<endl;
double
ans
=
sum
*
(
sum
+
1.0
)
/
2
+
10.0
*
sum
;
printf
(
"%.0f
\n
"
,
ans
);
double
ans
=
sum
*
(
sum
+
1.0
)
/
2
+
10.0
*
sum
;
printf
(
"%.0f
\n
"
,
ans
);
}
data/1.算法初阶/1.蓝桥杯/成绩分析/solution.cpp
浏览文件 @
f1d08c9c
#include<stdio.h>
#include<iostream>
#include
<stdio.h>
#include
<iostream>
using
namespace
std
;
int
main
()
{
int
n
;
cin
>>
n
;
int
sum
=
0
;
int
top
=
0
;
int
low
=
100
;
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
;
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
));
printf
(
"%d
\n
%d
\n
%.2lf"
,
top
,
low
,
(
sum
*
1.0
/
n
));
return
0
;
}
data/1.算法初阶/1.蓝桥杯/成绩统计/solution.cpp
浏览文件 @
f1d08c9c
#include<iostream>
#include
<iostream>
using
namespace
std
;
int
main
(){
struct
student
{
int
main
()
{
struct
student
{
string
xm
;
int
xh
;
double
yy
;
...
...
@@ -10,19 +12,25 @@ int main(){
};
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
;
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
;
if
(
max
<
sum
)
{
max
=
sum
;
maxs
=
a
[
i
].
xm
;
}
}
cout
<<
maxs
<<
endl
<<
mins
;
cout
<<
maxs
<<
endl
<<
mins
;
return
0
;
}
data/1.算法初阶/1.蓝桥杯/打印图形/solution.cpp
浏览文件 @
f1d08c9c
#include<cstdio>
#include
<cstdio>
#define N 70
void
f
(
char
a
[][
N
],
int
rank
,
int
row
,
int
col
)
{
if
(
rank
==
1
){
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(0,5,16,0) //处理左下角
f
(
a
,
rank
-
1
,
row
+
w
/
2
,
col
+
w
);
//f(0,5,16,16) //处理右下角
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(0,5,16,0) //处理左下角
f
(
a
,
rank
-
1
,
row
+
w
/
2
,
col
+
w
);
//f(0,5,16,16) //处理右下角
}
int
main
()
{
char
a
[
N
][
N
];
int
i
,
j
;
for
(
i
=
0
;
i
<
N
;
i
++
)
for
(
j
=
0
;
j
<
N
;
j
++
)
a
[
i
][
j
]
=
' '
;
int
i
,
j
;
for
(
i
=
0
;
i
<
N
;
i
++
)
for
(
j
=
0
;
j
<
N
;
j
++
)
a
[
i
][
j
]
=
' '
;
//f(a,6,0,0);
f
(
a
,
4
,
0
,
0
);
for
(
i
=
0
;
i
<
N
;
i
++
){
for
(
j
=
0
;
j
<
N
;
j
++
)
printf
(
"%c"
,
a
[
i
][
j
]);
for
(
i
=
0
;
i
<
N
;
i
++
)
{
for
(
j
=
0
;
j
<
N
;
j
++
)
printf
(
"%c"
,
a
[
i
][
j
]);
printf
(
"
\n
"
);
}
return
0
;
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/承压计算/solution.cpp
浏览文件 @
f1d08c9c
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include
<stdio.h>
#include
<string.h>
#include
<math.h>
#include
<algorithm>
using
namespace
std
;
typedef
long
long
ll
;
const
ll
maxn
=
1e6
+
50
;
const
ll
maxn
=
1e6
+
50
;
double
a
[
1050
][
1050
];
int
main
()
{
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
for
(
ll
j
=
1
;
j
<=
i
;
j
++
)
{
scanf
(
"%lf"
,
&
a
[
i
][
j
]);
scanf
(
"%lf"
,
&
a
[
i
][
j
]);
}
}
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
for
(
ll
i
=
1
;
i
<=
29
;
i
++
)
{
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
+
1
]
+=
(
0.5
*
a
[
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
++
)
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
]);
maxx
=
max
(
maxx
,
a
[
30
][
i
]);
minn
=
min
(
minn
,
a
[
30
][
i
]);
printf
(
"%lf
\n
"
,
a
[
30
][
i
]);
}
printf
(
"%lf
\n
"
,
maxx
*
2086458231
/
minn
);
printf
(
"%lf
\n
"
,
maxx
*
2086458231
/
minn
);
}
data/1.算法初阶/1.蓝桥杯/抽签/solution.cpp
浏览文件 @
f1d08c9c
#include <iostream>
using
namespace
std
;
int
a
[
10000
],
N
,
i
,
ans
=
0
;
void
findAns
(
int
a
[],
int
start
,
int
An
)
//国家可派出数组a,当前派出第start国家,已经组合An人
int
a
[
10000
],
N
,
i
,
ans
=
0
;
void
findAns
(
int
a
[],
int
start
,
int
An
)
//国家可派出数组a,当前派出第start国家,已经组合An人
{
if
(
start
==
N
)
//找到最后一个国家后
if
(
start
==
N
)
//找到最后一个国家后
{
if
(
An
==
5
)
ans
++
;
//如果组合人数An等于派出人数5;
return
;
if
(
An
==
5
)
ans
++
;
//如果组合人数An等于派出人数5;
return
;
}
for
(
i
=
0
;
i
<=
a
[
start
];
i
++
)
//派出第n个国家人数的人数,需检查人数是否满足规范
for
(
i
=
0
;
i
<=
a
[
start
];
i
++
)
//派出第n个国家人数的人数,需检查人数是否满足规范
{
findAns
(
a
,
start
+
1
,
An
+
i
);
//查找下一个国家,记录已经组合数An
}
findAns
(
a
,
start
+
1
,
An
+
i
);
//查找下一个国家,记录已经组合数An
}
}
int
main
()
{
//输入规模及数据
cin
>>
N
;
for
(
i
=
0
;
i
<
N
;
i
++
)
//输入规模及数据
cin
>>
N
;
for
(
i
=
0
;
i
<
N
;
i
++
)
{
cin
>>
a
[
i
];
cin
>>
a
[
i
];
}
findAns
(
a
,
0
,
0
);
cout
<<
ans
<<
endl
;
findAns
(
a
,
0
,
0
);
cout
<<
ans
<<
endl
;
return
0
;
}
data/1.算法初阶/1.蓝桥杯/搭积木/solution.cpp
浏览文件 @
f1d08c9c
//搭积木 768
#include<bits/stdc++.h>
#include
<bits/stdc++.h>
using
namespace
std
;
int
row
=
4
,
col
;
int
seq
[
5
][
8
];
//下标从1开始
int
row
=
4
,
col
;
int
seq
[
5
][
8
];
//下标从1开始
int
tmp
[
11
];
int
cnt
=
0
;
bool
used
[
10
];
void
change
(){
//将一维数组转换成二维数组
void
change
()
{
//将一维数组转换成二维数组
int
cur
=
1
;
for
(
int
i
=
1
;
i
<=
row
;
++
i
){
for
(
int
j
=
1
;
j
<=
i
;
++
j
){
seq
[
i
][
j
]
=
tmp
[
cur
++
];
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
;
}
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
;
void
dfs
(
int
idx
){
//idx:当前要操作的下标(从1开始)
if
(
idx
==
11
){
void
dfs
(
int
idx
)
{
//idx:当前要操作的下标(从1开始)
if
(
idx
==
11
)
{
change
();
if
(
judge
()){
if
(
judge
())
{
cnt
++
;
return
;
return
;
}
return
;
return
;
}
for
(
int
i
=
0
;
i
<=
9
;
++
i
){
if
(
!
used
[
i
]){
for
(
int
i
=
0
;
i
<=
9
;
++
i
)
{
if
(
!
used
[
i
])
{
tmp
[
idx
]
=
i
;
used
[
i
]
=
true
;
dfs
(
idx
+
1
);
...
...
@@ -46,9 +58,10 @@ void dfs(int idx){
}
}
int
main
(){
memset
(
used
,
false
,
sizeof
(
used
));
int
main
()
{
memset
(
used
,
false
,
sizeof
(
used
));
dfs
(
1
);
cout
<<
cnt
<<
endl
;
cout
<<
cnt
<<
endl
;
return
0
;
}
\ No newline at end of file
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/次数差/solution.cpp
浏览文件 @
f1d08c9c
...
...
@@ -4,8 +4,8 @@ int main() //计数排序
{
char
s
[
1000
];
scanf
(
"%s"
,
&
s
);
int
len
=
strlen
(
s
);
//获取字符串s的长度
int
helper
[
256
]
=
{
0
};
//ascll范围在0~255之间(包括0和255)
int
len
=
strlen
(
s
);
//获取字符串s的长度
int
helper
[
256
]
=
{
0
};
//ascll范围在0~255之间(包括0和255)
int
max
=
0
,
min
=
len
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
...
...
@@ -17,7 +17,7 @@ int main() //计数排序
{
max
=
helper
[
i
];
}
if
(
helper
[
i
]
<
min
&&
helper
[
i
]
!=
0
)
if
(
helper
[
i
]
<
min
&&
helper
[
i
]
!=
0
)
{
min
=
helper
[
i
];
}
...
...
data/1.算法初阶/1.蓝桥杯/比酒量/solution.cpp
浏览文件 @
f1d08c9c
#include<cstdio>
#include<iostream>
#include
<cstdio>
#include
<iostream>
using
namespace
std
;
int
d
,
a1
[
4
];
int
d1
(
int
*
a1
)
{
int
d1
(
int
*
a1
)
{
int
sum
=
a1
[
0
];
for
(
int
i
=
1
;
i
<
4
;
i
++
)
{
if
(
sum
%
a1
[
i
]
!=
0
)
return
i
;
for
(
int
i
=
1
;
i
<
4
;
i
++
)
{
if
(
sum
%
a1
[
i
]
!=
0
)
return
i
;
}
return
0
;
}
int
getS
(
int
*
a1
)
{
int
getS
(
int
*
a1
)
{
int
sum
=
0
,
ss
=
1
;
while
(
d1
(
a1
)
!=
0
)
{
while
(
d1
(
a1
)
!=
0
)
{
int
index
=
d1
(
a1
);
a1
[
0
]
=
a1
[
0
]
*
a1
[
index
];
ss
=
a1
[
index
];
}
for
(
int
i
=
1
;
i
<
4
;
i
++
)
{
sum
+=
(
a1
[
0
]
/
a1
[
i
]);
for
(
int
i
=
1
;
i
<
4
;
i
++
)
{
sum
+=
(
a1
[
0
]
/
a1
[
i
]);
}
return
sum
+
ss
;
return
sum
+
ss
;
}
int
main
()
{
for
(
int
sum
=
20
;
sum
>=
1
;
sum
--
)
{
for
(
int
a
=
1
;
a
<=
20
;
a
++
)
{
for
(
int
b
=
1
;
b
<=
20
;
b
++
)
{
for
(
int
c
=
1
;
c
<=
20
;
c
++
)
{
int
main
()
{
for
(
int
sum
=
20
;
sum
>=
1
;
sum
--
)
{
for
(
int
a
=
1
;
a
<=
20
;
a
++
)
{
for
(
int
b
=
1
;
b
<=
20
;
b
++
)
{
for
(
int
c
=
1
;
c
<=
20
;
c
++
)
{
a1
[
0
]
=
sum
,
a1
[
1
]
=
a
,
a1
[
2
]
=
b
,
a1
[
3
]
=
c
;
if
(
getS
(
a1
)
==
a1
[
0
]
&&
a
>
b
&&
b
>
c
&&
sum
>
a
)
{
if
(
getS
(
a1
)
==
a1
[
0
]
&&
a
>
b
&&
b
>
c
&&
sum
>
a
)
{
printf
(
"%d, %d, %d, %d, 0
\n
"
,
sum
,
a
,
b
,
c
);
}
}
}
}
}
...
...
data/1.算法初阶/1.蓝桥杯/波动数列/solution.cpp
浏览文件 @
f1d08c9c
#include<iostream>
#include<cstdio>
#include<cstring>
#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
;
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
;
int
dp
[
2
][
N
*
(
N
+
1
)
/
2
],
now
;
int
ans
;
int
main
()
{
scanf
(
"%d%d%d%d"
,
&
n
,
&
s
,
&
a
,
&
b
);
dp
[
now
][
0
]
=
1
;
for
(
int
i
=
1
;
i
<
n
;
++
i
)
//只有n-1个增量
scanf
(
"%d%d%d%d"
,
&
n
,
&
s
,
&
a
,
&
b
);
dp
[
now
][
0
]
=
1
;
for
(
int
i
=
1
;
i
<
n
;
++
i
)
//只有n-1个增量
{
now
=
!
now
;
up
=
i
*
(
i
+
1
)
/
2
;
for
(
int
j
=
0
;
j
<=
up
;
++
j
)
//01背包 容量 方案数
now
=
!
now
;
up
=
i
*
(
i
+
1
)
/
2
;
for
(
int
j
=
0
;
j
<=
up
;
++
j
)
//01背包 容量 方案数
{
dp
[
now
][
j
]
=
dp
[
!
now
][
j
];
if
(
j
>=
i
)
dp
[
now
][
j
]
=
(
dp
[
now
][
j
]
+
dp
[
!
now
][
j
-
i
])
%
mod
;
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
)
//s-i*a-(n*(n-1)/2-i)*b 是否被n整除
for
(
int
i
=
0
;
i
<=
up
;
++
i
)
//s-i*a-(n*(n-1)/2-i)*b 是否被n整除
{
v
=
1ll
*
s
-
1ll
*
i
*
a
+
1ll
*
(
up
-
i
)
*
b
;
if
(
v
%
n
==
0
)
ans
=
(
ans
+
dp
[
now
][
i
])
%
mod
;
v
=
1ll
*
s
-
1ll
*
i
*
a
+
1ll
*
(
up
-
i
)
*
b
;
if
(
v
%
n
==
0
)
ans
=
(
ans
+
dp
[
now
][
i
])
%
mod
;
}
printf
(
"%d
\n
"
,
ans
);
printf
(
"%d
\n
"
,
ans
);
return
0
;
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/测试次数/solution.cpp
浏览文件 @
f1d08c9c
#include <iostream>
using
namespace
std
;
int
num
[
5
][
1010
]
=
{
0
};
int
dp
(
int
k
,
int
n
)
int
num
[
5
][
1010
]
=
{
0
};
int
dp
(
int
k
,
int
n
)
{
int
res
=
10000
;
if
(
n
==
0
)
int
res
=
10000
;
if
(
n
==
0
)
return
0
;
if
(
k
==
1
)
if
(
k
==
1
)
return
n
;
if
(
num
[
k
][
n
])
if
(
num
[
k
][
n
])
return
num
[
k
][
n
];
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
{
res
=
min
(
res
,
max
(
dp
(
k
-
1
,
i
-
1
),
dp
(
k
,
n
-
i
))
+
1
);
res
=
min
(
res
,
max
(
dp
(
k
-
1
,
i
-
1
),
dp
(
k
,
n
-
i
))
+
1
);
}
num
[
k
][
n
]
=
res
;
num
[
k
][
n
]
=
res
;
return
res
;
}
int
main
()
{
cout
<<
dp
(
3
,
1000
)
<<
endl
;
cout
<<
dp
(
3
,
1000
)
<<
endl
;
return
0
;
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/猜字母/solution.cpp
浏览文件 @
f1d08c9c
#include<iostream>
#include<vector>
#include
<iostream>
#include
<vector>
using
namespace
std
;
int
main
()
{
vector
<
char
>
vc1
;
vector
<
char
>
vc1
;
int
i
;
for
(
i
=
0
;
i
<
2014
;
i
++
)
vc1
.
push_back
(
'a'
+
(
i
%
19
));
while
(
vc1
.
size
()
!=
1
)
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
)
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
;
vc1
.
assign
(
vc2
.
begin
(),
vc2
.
end
());
cout
<<
vc1
.
size
()
<<
endl
;
}
cout
<<
vc1
[
0
]
<<
endl
;
cout
<<
vc1
[
0
]
<<
endl
;
return
0
;
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/猜年龄/solution.cpp
浏览文件 @
f1d08c9c
#include<iostream>
#include
<iostream>
using
namespace
std
;
int
main
()
{
for
(
int
i
=
11
;
i
<
35
;
i
++
)
{
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
))
if
((
i1
>=
1000
&&
i1
<
10000
)
&&
(
i2
>=
100000
&&
i2
<
1000000
))
cout
<<
i
<<
" "
<<
i1
<<
" "
<<
i2
<<
endl
;
}
return
0
;
...
...
data/1.算法初阶/1.蓝桥杯/错误票据/solution.cpp
浏览文件 @
f1d08c9c
//代码3
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include
<iostream>
#include
<stdio.h>
#include
<string.h>
#include
<stdlib.h>
#include
<algorithm>
using
namespace
std
;
int
ans
[
10005
];
char
str
[
100001
];
int
main
()
{
int
n
;
cin
>>
n
;
int
i
,
k
=
0
;
cin
>>
n
;
int
i
,
k
=
0
;
getchar
();
for
(
i
=
0
;
i
<
n
;
i
++
)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
gets
(
str
);
char
*
p
;
p
=
strtok
(
str
,
" "
);
ans
[
k
++
]
=
atoi
(
p
);
while
(
p
)
p
=
strtok
(
str
,
" "
);
ans
[
k
++
]
=
atoi
(
p
);
while
(
p
)
{
p
=
strtok
(
NULL
,
" "
);
if
(
p
)
ans
[
k
++
]
=
atoi
(
p
);
p
=
strtok
(
NULL
,
" "
);
if
(
p
)
ans
[
k
++
]
=
atoi
(
p
);
}
}
sort
(
ans
,
ans
+
k
);
int
ans1
,
ans2
;
for
(
i
=
0
;
i
<
k
-
1
;
i
++
)
sort
(
ans
,
ans
+
k
);
int
ans1
,
ans2
;
for
(
i
=
0
;
i
<
k
-
1
;
i
++
)
{
if
(
ans
[
i
+
1
]
-
ans
[
i
]
==
2
)
if
(
ans
[
i
+
1
]
-
ans
[
i
]
==
2
)
{
ans1
=
ans
[
i
]
+
1
;
ans1
=
ans
[
i
]
+
1
;
}
if
(
ans
[
i
+
1
]
==
ans
[
i
])
ans2
=
ans
[
i
];
if
(
ans
[
i
+
1
]
==
ans
[
i
])
ans2
=
ans
[
i
];
}
cout
<<
ans1
<<
" "
<<
ans2
;
cout
<<
ans1
<<
" "
<<
ans2
;
}
\ No newline at end of file
data/1.算法初阶/1.蓝桥杯/马虎的算式/desc.md
浏览文件 @
f1d08c9c
小明是个急性子,上小学的时候经常把老师写在黑板上的题目抄错了。
有一次,老师出的题目是:36 x 495 = ?
他却给抄成了:396 x 45 = ?
但结果却很戏剧性,他的答案竟然是对的!!
因为 36
* 495 = 396 *
45 = 17820
类似这样的巧合情况可能还有很多,比如:27
* 594 = 297 *
54
假设 a b c d e 代表1~9不同的5个数字(注意是各不相同的数字,且不含0)
能满足形如: ab
* cde = adb *
ce 这样的算式一共有多少种呢?
请你利用计算机的优势寻找所有的可能,并回答不同算式的种类数。
满足乘法交换律的算式计为不同的种类,所以答案肯定是个偶数。
data/1.算法初阶/1.蓝桥杯/马虎的算式/solution.cpp
浏览文件 @
f1d08c9c
#include <iostream>
using
namespace
std
;
int
main
()
{
int
ans
=
0
;
for
(
int
a
=
1
;
a
<
10
;
a
++
)
{
for
(
int
b
=
1
;
b
<
10
;
b
++
)
{
if
(
b
!=
a
)
for
(
int
c
=
1
;
c
<
10
;
c
++
)
{
if
(
c
!=
b
&&
c
!=
a
)
for
(
int
d
=
1
;
d
<
10
;
d
++
)
{
if
(
d
!=
c
&&
d
!=
b
&&
d
!=
a
)
for
(
int
e
=
1
;
e
<
10
;
e
++
)
{
if
(
e
!=
d
&&
e
!=
c
&&
e
!=
b
&&
e
!=
a
)
{
// ab*cde=adb*ce;
if
((
a
*
10
+
b
)
*
(
c
*
100
+
d
*
10
+
e
)
==
(
a
*
100
+
d
*
10
+
b
)
*
(
c
*
10
+
e
))
ans
++
;
}
}
}
}
}
}
cout
<<
ans
<<
endl
;
return
0
;
}
data/1.算法初阶/1.蓝桥杯/马虎的算式/solution.java
浏览文件 @
f1d08c9c
public
class
MAHUSUANSHI
{
public
static
void
main
(
String
[]
args
)
{
int
ans
=
0
;
for
(
int
a
=
1
;
a
<
10
;
a
++)
{
for
(
int
b
=
1
;
b
<
10
;
b
++)
{
if
(
b
!=
a
)
for
(
int
c
=
1
;
c
<
10
;
c
++)
{
if
(
c
!=
a
&&
c
!=
b
)
for
(
int
d
=
1
;
d
<
10
;
d
++)
{
if
(
d
!=
a
&&
d
!=
b
&&
d
!=
c
)
for
(
int
e
=
1
;
e
<
10
;
e
++)
{
if
(
e
!=
a
&&
e
!=
b
&&
e
!=
c
&&
e
!=
d
)
{
if
((
a
*
10
+
b
)
*
(
c
*
100
+
d
*
10
+
e
)
==
(
a
*
100
+
d
*
10
+
b
)
*
(
c
*
10
+
e
))
{
ans
++;
System
.
out
.
printf
(
"(d%*10+d%)*(d%*100+d%*10+d%)==(d%*100+d%*10+d%)*(d%*10+d%)==d%\n"
,
a
,
b
,
c
,
d
,
e
,
a
,
d
,
b
,
c
,
e
,
(
a
*
10
+
b
)
*
(
c
*
100
+
d
*
10
+
e
)
==
(
a
*
100
+
d
*
10
+
b
)
*
(
c
*
10
+
e
));
}
}
}
}
}
}
}
System
.
out
.
println
(
ans
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录