1 条题解
-
0
【深基1.习4】简单的分苹果 3
解题思路
设学生数为 n,则苹果数同时等于 3n+11 与 4n-1。联立得到 n=12,苹果 47 个。
正确性说明
两种分法相等给出 n=12,代入后 36+11=47、48-1=47,满足两个条件。
易错点
少一个表示现有数量比所需少 1;学生数在前。
复杂度
时间 O(1),空间 O(1)。
参考代码(C++11)
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n = 11 + 1; cout << n << " " << 3 * n + 11 << "\n"; return 0; }
- 1