You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python/TangDou/Mkx/2023.8.20 _码客行_编程公益课 在线评估.md

325 lines
9.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## 2023.8.20 _码客行_编程公益课 在线评估
1. 师大附小六年级学生有$400$名学生参加期末测试,平均$92$分,其中男生的平
均分为$96$分,女生的平均分为$80$分,参加竞赛的男生比女生多多少人?
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main()
{
cout<<"男生比女生多"<< 200 <<"人。"<<endl;
return 0;
}
```
**解:简单方程,略**
2. 奇奇和马克在学习进位加法,可是他俩还是喜欢不进位的计算。于是他俩想知道$0$~$5999$中有多少个数与$1234$相加时,不会发生进位。
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main(){
cout<<”有”<< <<”个数。”<<endl;
return 0
}
```
**解** 本题考查乘法原理
千位可取值为$(0-8)$
百位可取值为$(0-7)$
十位可取值为$(0-6)$
个位可取值为$(0-5)$
所以一共有$9*8*7*6=3024$
但是,由于$0 \sim 5999$,所以千位上要有限制,最大不能到达$6$,也就是$0 \sim 5$,
$6*8*7*6$
> **练习题**
> 在$1$到$9999$有多少个正整数在与$4567$相加时,至少在一个数位中发生进位
> **答案**:考虑都不进位的情况
千位可取值为$(0-5)$
百位为$(0-4)$
十位为$(0-3)$
个位为$(0-2)$
所以一共有$6*5*4*3-1=359$个
发生进位的数有$9999-359=9640$个
1. 奇奇和马克在马路一侧同向而行。马克步行,行走速度为$3.6$千米/时。奇奇
骑着自行车,速度为$10.8$千米/时。这时有一辆公共汽车从他们背后开过来,
公共汽车通过马克用了$6$秒,通过奇奇用了$10$秒。请计算并输出这辆公共汽
车车身的长度。(单位:米)
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main(){
cout<<”这辆公共汽车车身长度为”<< 30 <<”米。”<<endl;
return 0;
}
```
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202308210805721.png)
**注:本题考查千米/小时转化为 米/秒后进行计算**
4. 马克用橡皮泥捏了一些特殊的动物形象。动物$1$有$1$头$1$脚、动物$2$有$2$头$4$
脚、动物$3$有$1$头$3$脚、动物$4$有$1$头$4$脚。所有橡皮泥捏完后,马克数了一下
所有动物共有$45$个头、$119$只脚,且动物$4$的数量恰好是动物$2$的$2$倍,现在
请你计算并输出动物$1$有多少只?
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main(){
cout<<”动物1有”<< 8 <<”只。”<<endl;
return 0;
}
```
解:
$$
\large \left\{\begin{matrix}
a+2b+c+d=45 & \\
a+4b+3c+4d=119 & \\
d=2b & \\
\end{matrix}\right.
$$
代入 ①,② 得到
$$
\large \left\{\begin{matrix}
a+4b+c=45 & \\
a+12b+3c=119 &
\end{matrix}\right.
$$
$\times$ $3$
$$
\large \left\{\begin{matrix}
3a+12b+3c=135 & \\
a+12b+3c=119 &
\end{matrix}\right.
$$
上下相减
得到$2a=16$
解得$a=8$
5. 爸爸、妈妈、马克三人的苹果数不一样,爸爸的苹果最多,他拿出一些分给
妈妈和马克,使得妈妈和马克的苹果数都比原来增加了$2$倍,现在妈妈的苹
果数又最多,妈妈又拿出一些分给爸爸和马克,使爸爸和马克的苹果数各增
加了$2$倍,最后马克的苹果数又最多,最后,马克也拿出一些分给爸爸和妈
妈,使爸爸和妈妈的苹果数各增加$2$倍。最终三个人的苹果数一样多,他们
三人一共有$162$个苹果 ,求三人原来各有多少个苹果?爸爸( )个,妈妈(
)个,马克( )个。
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main()
{
cout<<”最初,爸爸有”<<110 <<”个苹果,妈妈有”<<38 <<”个苹
果,马克有”<<14 <<”个苹果。”;
return 0
}
```
倒推法,不再赘述
6.由于绘画工的辞职,马克所在的公司剩下一批需要绘画的工作,同时公司每
天还有新的固定数量的绘画工作增加。绘画工作是以页计数的,且每个绘画
工工作速度是相同固定的。秘书告诉马克,如果现在雇佣$5$名工人,$24$天可
以完成所有工作;如果聘用$9$名工人,$12$天可以完成所有工作。最终,马克
聘用了一些员工,工作$8$天后,由于业务减少,每天新增的工作量降为原来
的一半,最终这些员工用$40$天刚好完成了所有的工作。请计算并输出马克实
际聘用的员工数。
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main(){
cout<<”马克实际雇佣了”<< 3 <<”名员工。”<<endl;
return 0;
}
```
解:
设原有的任务数为$S$,每天增加的为$V$,最终雇佣了$n$个员工,则有方程:
$5*24=S+24*V$
$9*12=S+12*V$
解方程得$12V=12$
$\therefore V=1,S=96$
$S+8*V+1/2*V*32=40*n$
将值代入
$96+8+16=40n$
$n=3$
<font color='red' size=4><b>总结:就是一个披着雇佣工人外貌的牛吃草问题</b></font>
7. 马克入住的宾馆$2$楼有$20$个房间,此时房间所有灯都是开着的。马克从$1$号房
间开始,第一次按下$1$号房间的开关,第二次按下$2,3$号房间的开关,第三次
按下$4,5,6$号房间的开关,……第$20$次按下所有房间的开关。请问,最后灯
亮着的房间数。
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main(){
cout<<”最后亮灯的房间有”<< 10 <<”间。”<<endl;
return 0;
}
```
解:
**最开始灯都是开着的,所以,按奇数下是关了,按偶数下是开了**
```cpp {.line-numbers}
#include <bits/stdc++.h>
using namespace std;
const int N = 21;
int b[N];
int main() {
int start = 1;
for (int i = 1; i <= 20; i++) {
cout << "i=" << i << ",按下的房间号:";
for (int j = start; j < start + i; j++) {
if (j > 20) {
b[j - 20]++;
cout << j - 20 << " ";
} else {
b[j]++;
cout << j << " ";
}
}
cout << endl;
start = start + i;
if (start > 20) start = start - 20;
}
int cnt = 0;
for (int i = 1; i <= 20; i++)
if (b[i] % 2 == 0) cnt++;
cout << "最后亮灯的房间数:" << cnt << endl;
return 0;
}
```
```cpp {.line-numbers}
i=1按下的房间号1
i=2按下的房间号2 3
i=3按下的房间号4 5 6
i=4按下的房间号7 8 9 10
i=5按下的房间号11 12 13 14 15
i=6按下的房间号16 17 18 19 20 1
i=7按下的房间号2 3 4 5 6 7 8
i=8按下的房间号9 10 11 12 13 14 15 16
i=9按下的房间号17 18 19 20 1 2 3 4 5
i=10按下的房间号6 7 8 9 10 11 12 13 14 15
i=11按下的房间号16 17 18 19 20 1 2 3 4 5 6
i=12按下的房间号7 8 9 10 11 12 13 14 15 16 17 18
i=13按下的房间号19 20 1 2 3 4 5 6 7 8 9 10 11
i=14按下的房间号12 13 14 15 16 17 18 19 20 1 2 3 4 5
i=15按下的房间号6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
i=16按下的房间号1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
i=17按下的房间号17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13
i=18按下的房间号14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11
i=19按下的房间号12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10
i=20按下的房间号11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10
最后亮灯的房间数:10
```
8. 一个快钟每时比标准时间快$8$分,一个慢钟每时比标准时间慢$7$分。将两个钟
同时调到标准时间,结果在$24$时内,快钟显示$9$点整时,慢钟恰好显示$7$点整。
此时的标准时间是多少?
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main(){
cout<<”此时的标准时间是”<< <<”点”<< <<”分”<<endl;
return 0;
}
```
**解**
每小时快钟比慢钟快$8+7=15$分钟,$9$点与$7$点相差$120$分钟,即走了$120÷15=8$小时,故快钟比标准时间快了$8×8=64$分钟,即此时的标准时间是$7$点$56$分。
9. 一个自然数除$429$、$791$、$500$所得的余数分别是$x+5$、$2x$、$x$,这个自然数是多少?
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main()
{
cout<<”这个自然数是”<< <<”。”<<endl;
return 0;
}
```
**编码解法**
```cpp {.line-numbers}
#include <bits/stdc++.h>
using namespace std;
int main() {
for (int i = 1;; i++) {
int a = 429 % i, b = 791 % i, c = 500 % i;
if (a == c + 5 && b == 2 * c) {
cout << i << endl;
cout << "a=" << a << ",b=" << b << ",c=" << c << endl;
break;
}
}
return 0;
}
```
**数学解法**
设这个数为$K$,得:
$429-(x+5)=mK$,
$429-(x+5)=mK -> 424=mK+x$
$791-2x=nK \ \ \ \ \ \ \ \ \ -> 791=nK+2x$
$500-x=pK \ \ \ \ \ \ \ \ \ \ \ -> 500=pK+x$
得:$76=(p-m)K$
$57=(2m-n)K$
$209=(2p-n)K$
所以$K$是$76,57,209$的公约数
$76=4*19$
$57=3*19$
$209=11*19$
所以$K$为$19$.
10. 马克的碗中有纯蔗糖 $100$ 克,奇奇的杯子中有水 $200$ 克。首先,马克将部
分纯蔗糖倒入奇奇的杯子里。接着,奇奇又将自己杯子中的糖水倒入马克的碗中。
此时,马克碗中蔗糖含量为 $50\%$ ,奇奇杯子中蔗糖含量为$25\%$。
现在请你计算并输出马克碗里此时有糖水多少克?
```cpp {.line-numbers}
#include<iostream>
using namespace std;
int main(){
cout<<”奇奇杯子中此时有糖水”<< 100 <<”克。”<<endl;
return 0;
}
```
**解**
不管你中间怎么折腾,最终的糖和水的重量不会改变。
设最后马克碗中糖水重为$x$克,则奇奇杯中糖水重为$100+200-x$克。
$50\% \times x + (300-x) \times 25 \%=100$
$0.5x+75-0.25x=100$
$x=100$