leetcode492
public class Solution {
public int[] ConstructRectangle(int area)
{
Dictionary<int, int> dic = new Dictionary<int, int>();
for (int i = ; i <= area; i++)
{
var W = i;
var L = Convert.ToInt32(area / i);
if (L >= W && W * L == area)
{
dic.Add(L, W);
}
}
var d = dic.LastOrDefault();
var ary = new int[] { d.Key, d.Value };
Console.WriteLine("L=" + ary[] + ",W=" + ary[]);
return ary;
}
}
https://leetcode.com/problems/construct-the-rectangle/#/description
leetcode492的更多相关文章
- [Swift]LeetCode492. 构造矩形 | Construct the Rectangle
For a web developer, it is very important to know how to design a web page's size. So, given a speci ...
- Leetcode492.Construct the Rectangle构造矩形
作为一位web开发者, 懂得怎样去规划一个页面的尺寸是很重要的. 现给定一个具体的矩形页面面积,你的任务是设计一个长度为 L 和宽度为 W 且满足以下要求的矩形的页面.要求: 1. 你设计的矩形页面必 ...
随机推荐
- 《DSP using MATLAB》 Problem 4.9
代码: %% ---------------------------------------------------------------------------- %% Output Info a ...
- freemarker在js中的应用
<script type="text/javascript"> //freemarker在js中的应用: var newOrganizations = []; < ...
- js操作链接url
使用js对当前的URL进行操作,可以使用内置对象window.location: window.location有以下属性: window.location.href:取得当前地址栏中的完整URL,可 ...
- WIFI学习笔记
1.关掉网卡:sudo ifconfig eth0 down $ ifconfig -a显示出所有的网卡,down的也可以显示出来,而$ ifconfig只能显示up状态的网卡,最好先停掉网络服务再开 ...
- MySQL Transaction--快照读和当前读
在MySQL读取数据时可以按照是否使用一致性非锁定读来分为快照读和当前读:1.快照读:MySQL使用MVCC (Multiversion Concurrency Control)机制来保证被读取到数据 ...
- FastAdmin 开发第三天:安装 FastAdmin
环境安装安装好后就可以安装 FastAdmin 了. 根据文档说明安装步骤如下,推荐使用命令行安装: 克隆FastAdmin到你本地 git clone https://git.oschina.net ...
- [转]Maven中profile和filtering实现多个环境下的属性过滤
背景 项目构建的时候,需要根据不同的场景来改变项目中的属性资源,最为常见的莫过于数据库连接配置了,试想有生产环境.测试缓存.发布环境等,需要为不同的场景下来动态的改变数据库的连接配置.而使用maven ...
- JUC集合之 ConcurrentHashMap
ConcurrentHashMap介绍 ConcurrentHashMap是线程安全的哈希表. HashMap, Hashtable, ConcurrentHashMap之间的关联如下: HashMa ...
- VS2010 C++编译报错LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
查找是否有两个cvtres.exe.一个是C:\Program Files(x86)\Microsoft Visual Studio 10.0\vc\bin\cvtres.exe, 另一个是C:\Wi ...
- MySQL集群Percona XtraDB Cluster安装搭建步骤详解
http://www.linuxidc.com/Linux/2017-05/143501.htm http://blog.csdn.net/thundermeng/article/details/52 ...