leetcode479
public class Solution
{
public int LargestPalindrome(int n)
{
if (n == ) return ;
int max = (int)Math.Pow(, n) - ;
for (int v = max - ; v > max / ; v--)
{
StringBuilder sb = new StringBuilder();
foreach (var c in v.ToString().Reverse())
{
sb.Append(c);
}
long u = Convert.ToInt64(v.ToString() + sb.ToString());
for (long x = max; x * x >= u; x--)
if (u % x == )
return (int)(u % );
}
return ;
}
}
https://leetcode.com/problems/largest-palindrome-product/description/
leetcode479的更多相关文章
- [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...
随机推荐
- hdu 5890 Eighty seven 暴力+bitset优化背包
Eighty seven Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others) P ...
- js添加后缀防止缓存
jsp页面: 时间戳的话需要引入: <%@ page import="java.util.Date"%> <script type="text/java ...
- shutdown TCP 端口445
一. 协议:TCP 端口:445 二. shutdown /m \\192.168.1.15 -s -t 60 net use \\192.168.1.15\ipc$ 密码 /user:账户 三. g ...
- ps常用键
@updata 2016-7-31 切图 界面设置 视图 --显示 ---智能参考线 72 标尺 ctrl + r 窗口 ----信息 字符 历史记录 颜色 选RGB 信息图选项 ...
- ItemsControl 与 ICollectionView
ItemsControl base class can automatically interact with ICollectionView classes
- T-SQL_面试题
创建表插入数据 Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,score) 成绩表 Teacher(T#,Tname ...
- java中如何将string 转化成long
1.Java中如何将string 转化成long long l = Long.parseLong([String]); 或 long l = Long.parseLong([String],[int ...
- ural 2017 Best of a bad lot
2017. Best of a bad lot Time limit: 1.0 secondMemory limit: 64 MB A cruise liner hasn’t moved away f ...
- hdu 5236 Article(概率dp¥)
Article Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- CCEditBox
EditBox 创建添加 以及 一些函数参数的解析 #include "GUI/CCEditBox/CCEditBox.h" #include "GUI/CCContro ...