Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
335144 | 小林老师 | 【C3-T】童童的三角形 | C++ | 通过 | 100 | 2 MS | 252 KB | 778 | 2025-07-21 22:46:23 |
#include <iostream> #include <algorithm> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; // 将三条边排序,方便判断 int sides[3] = {a, b, c}; sort(sides, sides + 3); int x = sides[0], y = sides[1], z = sides[2]; // x ≤ y ≤ z // 检查是否为直角三角形 if (x * x + y * y == z * z) { cout << z * z << endl; // 是直角三角形,输出斜边平方 } else { // 不是直角三角形,计算所有可能的两边组合的斜边平方 int max_hypotenuse_square = max({ x * x + y * y, x * x + z * z, y * y + z * z }); cout << max_hypotenuse_square << endl; } return 0; }