3000. 对角线最长的矩形的面积

3000. 对角线最长的矩形的面积


题目链接:3000. 对角线最长的矩形的面积

代码如下:

cpp 复制代码
class Solution {
public:
	int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {
		double maxDiagonalLength = 0;
		int res = 0;
		for (vector<int>& dimension : dimensions) {
			int h = dimension[0];
			int w = dimension[1];
			if (maxDiagonalLength < sqrt(h * h + w * w) ||
				(maxDiagonalLength == sqrt(h * h + w * w) && res < h * w)) {
				maxDiagonalLength = sqrt(h * h + w * w);
				res = h * w;
			}
		}
		return res;
	}
};
相关推荐
王老师青少年编程19 分钟前
csp信奥赛C++高频考点专项训练之贪心算法 --【贪心与二分判定】:数列分段 Section II
c++·算法·贪心·csp·信奥赛·二分判定·数列分段 section ii
zh_xuan21 分钟前
libcurl调用https接口
c++·libcurl
就叫飞六吧22 分钟前
QT写一个桌面程序exe并动态打包基本流程(c++)
开发语言·c++
蜡笔小马24 分钟前
1.c++设计模式-工厂模式
c++
汉克老师1 小时前
GESP2025年3月认证C++五级( 第三部分编程题(2、原根判断))
c++·算法·模运算·gesp5级·gesp五级·原根·分解质因数
winner88811 小时前
从零吃透C++命名空间、std、#include、string、vector
java·开发语言·c++
AI进化营-智能译站2 小时前
ROS2 C++开发系列07-高效构建机器人决策逻辑,运算符与控制流实战
开发语言·c++·ai·机器人
winner88812 小时前
C++ 命名空间、虚函数、抽象类、protected 权限全套通俗易懂精讲(附与 Java 对比)
java·开发语言·c++
不会编程的懒洋洋2 小时前
C# P/Invoke 基础
开发语言·c++·笔记·安全·机器学习·c#·p/invoke
24白菜头2 小时前
【无标题】
c++·笔记·学习·harmonyos