抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

蓝桥杯省赛 B组 十一届 第二场

试题A:门牌制作

十一届—试题A门牌制作

答案:624

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*************************************************************************
> File Name: 十一届—试题A门牌制作.cppz
> Author:
> Mail:
> Created Time: 2021年02月28日 星期日 16时31分53秒
************************************************************************/

#include <iostream>
using namespace std;

const int MAX_N = 2020;

int f[MAX_N + 10];

int main() {
int n = 0;
for (int i = 1; i <= 2020; i++) {
int t = i;
while (t) {
if (t % 10 == 2) n++;
t /= 10;
}
}
cout << n << endl;
return 0;
}

试题B:既约分数

试题B既约分数

答案:2481215

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
/*************************************************************************
> File Name: 十一届—试题B既约分数.cpp
> Author:
> Mail:
> Created Time: 2021年02月28日 星期日 19时46分32秒
************************************************************************/

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
int n = 0;
for (int i = 1; i <= 2020; i++) {
for (int j = 1; j <= 2020; j++) {
if(__gcd(i, j) == 1) n++;
}
}
cout << n << endl;
return 0;
}

试题C:蛇形填数

image-20210301124330651

题解思路:

有题目可以得出, 红色偶数是斜着向下,蓝色奇数是斜着向上由此可以写出代码。

img

答案:761

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*************************************************************************
> File Name: 蛇形填数.cpp
> Author:
> Mail:
> Created Time: 2021年02月28日 星期日 20时08分21秒
************************************************************************/

#include <iostream>
using namespace std;

const int MAX_N = 40;

int f[MAX_N][MAX_N];

int main() {
int n = 1;
for (int i = 1; i <= MAX_N; i++) {
if (i & 1) { // 奇数的情况
for (int x = i, y = 1; x >= 1 && y <= i; x--, y++) {
f[x][y] = n++;
}
} else {
for (int x = 1, y = i; x <= i && y >= 1; x++, y--) {
f[x][y] = n++;
}
}
}

for (int i = 1; i <= 20; i++) {
for (int j = 1; j <= 20; j++) {
cout << f[i][j] << " ";
}
cout << endl;
}
return 0;
}

试题D:跑步锻炼

image-20210301125936220

答案:8879

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*************************************************************************
> File Name: 跑步锻炼.cpp
> Author:
> Mail:
> Created Time: 2021年03月01日 星期一 13时00分05秒
************************************************************************/

#include <iostream>
using namespace std;

// 列出所有月份之后 在特殊处理 2 月
int m[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int leap_year(int x) {
if ((x % 4 == 0 && x % 100 != 0) || x % 400 == 0) return 1;
return 0;
}

int main() {
int s = 0;
int mark = 6;
// 这里题目给出 2000 年 至 2020 年 因为题目给出 2020年不是整月所以就单处理一下
for (int i = 2000; i < 2020; i++) {
if (leap_year(i)) m[2] = 29;
else m[2] = 28;
for (int j = 1; j <= 12; j++) {
for (int k = 1; k <= m[j]; k++) {
if (mark % 7 == 1 || k == 1) s += 2;
else s++;
mark++;
}
}
}
// 闰年 29 平年 28
if (leap_year(2020)) m[2] = 29;
else m[2] = 28;

for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= m[i]; j++) {
if (mark % 7 == 1 || j == 1) s += 2;
else s++;
mark++;
}
}
// 题目要求 只道 10 月 1 日 由于还是 月初 所以加上 + 2
cout << s + 2;
return 0;
}

试题E:七段码

image-20210301145020703

答案:80

来源于网上一个大佬 枚举出所有情况的做法

img

$$
上面是一道结果填空的题,你只需要算出结果后提交即可。本题的结果为一 个整数,在提交答案时只填写这个整数,填写多余的内容将无法得分
$$

试题F:成绩统计

image-20210301154012206

image-20210301154258297

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
int n;
int E = 0, G = 0;
cin >> n;
for (int i = 0; i < n; i++) {
int t;
cin >> t;
if (t > 60) G++;
if (t > 85) E++;
}
int t = E * 100.0 / n + 0.5;
int t1 = G * 100.0 / n + 0.5;
printf("%d%%\n%d%%", t1, t);
return 0;
}

评论