以下是用 C++ 语言解决此问题的代码: ```cpp #include <iostream> int countContests(int n) { if (n == 1) { return 3; } int numNewbie = (n - 1) / 1; int numCSPJ = (n - 1) / 2; int numCSPS = (n - 1) / 3; int total = 0; if (numNewbie > 0 && n % 1 == 0) { total++; } if (numCSPJ > 0 && n % 2 == 0) { total++; } if (numCSPS > 0 && n % 3 == 0) { total++; } return total; } int main() { int n; std::cout << "请输入周数: "; std::cin >> n; int contests = countContests(n); std::cout << "第 " << n << " 周将举办 " << contests << " 场比赛。" << std::endl; return 0; } ``` [2024-09-07 23:37:15 | AI写代码神器 | 281点数解答]