题解:P2433 【深基1-2】小学数学 N 合一
static_summer · · 题解
一题一题慢慢看吧。
第一题
题目分析: 直接输出指定字符串。
解题思路: 使用 cout 输出即可。
cout << "I love Luogu!";
第二题
题目分析: 计算苹果分配情况。
解题思路:
前两人共拿走:
2 + 4 = 6 个。第三人拿走:
10 - 6 = 4 个。cout << 6 << " " << 4;第三题
题目分析: 苹果分配问题。
解题思路:
每人分得:
14 \div 4 = 3 \dots \dots 2 个。共分出:
3 \times 4 = 12 个。剩余:
14 - 12 = 2 个。
cout << 3 << endl << 12 << endl << 2;
第四题
题目分析: 浮点数除法。
解题思路:
注意使用浮点运算。
cout << fixed << setprecision(3) << 500.0 / 3;
第五题
题目分析: 火车相遇问题。
解题思路:
$(260 + 220) \div (12 + 20) = 15$ 秒。 ```cpp cout << (220 + 260) / (20 + 12); ``` ### 第六题 **题目分析:** 勾股定理应用。
解题思路:
对角线长度=
\sqrt{6^2 + 9^2} 。
cout << sqrt(6 * 6 + 9 * 9);
第七题
题目分析: 账户余额计算。
解题思路:
初始
100 \to +10 = 110 。$90 \to 0$(取成完了,只剩零元)。
cout << 110 << endl << 90 << endl << 0;
第八题
题目分析: 圆的相关计算。
解题思路:
周长:
2 \times \pi \times r 。面积:
\pi \times r^2 。体积:
\frac{4}{3} \times \pi \times r^3 。
int r = 5;
cout << 2 * pi * r << endl;
cout << pi * r * r << endl;
cout << 4.0 / 3 * pi * r * r * r << endl;
第九题
题目分析: 倒推法解决吃桃问题。
解题思路:
第四天:
1 。第三天:
(1 + 1) \times 2 = 4 。第二天:
(4 + 1) \times 2 = 10 。第一天:
(10 + 1) \times 2 = 22 。cout << 22;第十题
题目分析: 二元一次方程应用。
解题思路:
设初始
x 任务,每分钟新增y 。列方程组:
\begin{cases} 8 \times 30 = x + 30 \times y \\ 10 \times 6 = x + 6 \times y \end{cases} 解方程组得
x = 15 ,y = 7.5 。十分钟需要:
(15 + 75) \times 10 = 9 台。
cout << 9;
第十一题
题目分析: 追及问题。
解题思路:
$100 \div (8 - 5) = 33.333 \dots$。 ```cpp cout << 100.0 / 3; ``` ### 第十二题 **题目分析:** 字母表位置。
解题思路:
M是第十三个字母。第十八个字母是
R。
cout << 'M' - 'A' + 1 << endl;
cout << (char)('A' + 17);
第十三题
题目分析: 体积转换。
解题思路:
计算两球体积和。
开立方后取整。
double v = 4.0 / 3 * pi * (64 + 1000);
cout << (int)pow(v, 1.0 / 3);
第十四题
题目分析: 一元二次方程求解。
解题思路:
设定价
x ,人数120 - x 。解
x (120 - x) = 3500 。取较小解
x = 50 。
cout << 50;
完整代码:
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
const double pi = 3.141593;
cin >> T;
if (T == 1) {
cout << "I love Luogu!";
} else if (T == 2) {
cout << 6 << " " << 4;
} else if (T == 3) {
cout << 3 << endl << 12 << endl << 2;
} else if (T == 4) {
cout << fixed << setprecision(3) << 500.0 / 3;
} else if (T == 5) {
cout << 15;
} else if (T == 6) {
cout << sqrt(36 + 81);
} else if (T == 7) {
cout << 110 << endl << 90 << endl << 0;
} else if (T == 8) {
cout << 2 * pi * 5 << endl;
cout << pi * 25 << endl;
cout << 4.0 / 3 * pi * 125 << endl;
} else if (T == 9) {
cout << 22;
} else if (T == 10) {
cout << 9;
} else if (T == 11) {
cout << 100.0 / 3;
} else if (T == 12) {
cout << 13 << endl << 'R';
} else if (T == 13) {
cout << (int)pow(4.0 / 3 * pi * (64 + 1000), 1.0 / 3);
} else if (T == 14) {
cout << 50;
}
return 0;
}
AC 记录