AT. 1001-程序阅读题
1001-程序阅读题
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int cnt2 = n / 2;
int cnt3 = n / 3;
int cnt6 = n / 6;
int ans = cnt2 + cnt3 - cnt6; // (1)
cout << ans;
return 0;
}
- 若输入 10,则输出 7 {{ select(1) }}
- A对
- B错
- 程序的功能为:统计 1~n 中能被 2 或 3 整除的数的个数 {{ select(2) }}
- A对
- B错
- 若把 (1) 改为 cnt2 + cnt3 程序仍然正确 {{ select(3) }}
- A对
- B错
选择题
- 若输入 12,则输出 {{ select(4) }}
- 8
- 7
- 6
- 9
- 若要统计“既不能被 2 也不能被 3 整除”的数,应输出 {{ select(5) }}
- n - ans
- ans
- n - cnt2
- n - cnt3
- 若要扩展为统计能被 2、3、5 至少一个整除,应增加 {{ select(6) }}
- 减去两两交集
- 加上三者交集
- 减去三者交集
- 以上都需要 答案:
AAB
AAD