Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
108943 彭士宝 生理周期 C++ Compile Error 0 MS 0 KB 695 2025-01-23 17:15:17

Tests(0/0):


Code:

#include <iostream> using namespace std; // 计算最小公倍数 int lcm(int a, int b) { return (a * b) / gcd(a, b); } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int p, e, i, d; cin >> p >> e >> i >> d; // 计算三个周期的最小公倍数 int cycle = lcm(23, lcm(28, 33)); // 找到下一次三高峰同一天 int nextPeak = (max(p, max(e, i)) + cycle - 1) / cycle * cycle; // 计算距离d的天数 int days = nextPeak - d; if (days < 0) { days += cycle; } cout << "the next triple peak occurs in " << days << " days." << endl; return 0; }


Run Info:

Main.cc: In function 'int lcm(int, int)':
Main.cc:6:30: error: 'gcd' was not declared in this scope
     return (a * b) / gcd(a, b);
                              ^