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的更多相关文章

  1. [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product

    Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...

随机推荐

  1. ubuntu12.04 错误:phonon: No such file or directory; phonon模块的安装

    http://blog.csdn.net/xsl1990/article/details/9009919 错误:phonon: No such file or directory 1)sudo  ap ...

  2. Teamviewer_相关

    1.官网下载:https://www.teamviewer.com/zhcn/download/windows/,里面选择 "Portable"的版本来下载(按钮"下载P ...

  3. nova rebuild

    nova rebuild¶ usage: nova rebuild [--rebuild-password <rebuild-password>] [--poll] [--minimal] ...

  4. volume image

    http://docs.openstack.org/user-guide/cli_nova_launch_instance_from_volume.html http://docs.openstack ...

  5. openstack live migration性能分析

    http://blog.zhaw.ch/icclab/an-analysis-of-the-performance-of-live-migration-in-openstack/ http://blo ...

  6. Python的常见几道数学运算题

    一 python 相关数学函数及使用示例 常用的数学函数: ceil(x) 取顶 floor(x) 取底 fabs(x) 取绝对值 factorial (x) 阶乘 hypot(x,y)  sqrt( ...

  7. 卸载 Oracle 的 JDK

    mac $ java -version java version "1.8.0_66" Java(TM) SE Runtime Environment (build 1.8.0_6 ...

  8. asp.net上传文件大小限制

    <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedConte ...

  9. 开始学Python

    怎么说,整体还是比较愚昧的.不知道该干什么,大学里学过C++,C语言,忘的差不多了.毕业了做的是SAP,自学过一段JAVA.总是东一榔头西一棒子,借口还是多. 那就说一些现状嘛,语言重在的是应用这个方 ...

  10. 一个丰富的通知工具类 --第三方开源--NotifyUtil

    把NotifyUtil Copy进自己的项目就好 实现有八种,作者在Demo里全部演示齐了,分别是 普通类型通知(单行) 普通类型通知(多行) 消息列表通知(含双图标) 含大图类型通知 自定义视图通知 ...