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. psd文件中截取固定大小的图片

    1.选择需要操作的图层 使用选框工具, 设置固定大小和固定大小的值,在图层上拉取选区 2.使用移动工具  使用垂直.水平居中 使选择的icon在选区块中间 3.再选择好块区域调整好位置后 使用截取工具 ...

  2. php中浮点型变量

    $d = (0.1+0.7)*10;//$d为8 //floor函数返回不大于value的最接近的整数,舍去小数部分取整 $e = floor($d);//$e为7 为什么$e为7,而不是8 因为$d ...

  3. Eclipse导出apk

    http://jingyan.baidu.com/article/7908e85c8dea30af491ad24f.html

  4. Mysql5.7压缩版安装启动不了的问题

    从mysql 官网下载了mysql-5.7.12-winx64.zip的文件.按步骤安装: 1.添加环境变量     操作如下:     1)右键单击我的电脑->属性->高级系统设置(高级 ...

  5. spring boot + thymeleaf 报错 org.thymeleaf.exceptions.TemplateInputException

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template "admin/verifyPassword ...

  6. mybatis中>=和<=的实现方式

    原因 mybatis使用的是xml格式的文件.使用>和<号的时候,会存在与xml的标签的规范冲突. 解决方案 >=使用 <![CDATA[>=]]> >< ...

  7. webpack vue-cli 一有空格和分号就报错

    webpack vue-cli 一有空格和分号就报错 eslintrc.js 这是ESLint的配置文件,至于为什么用ESLint的话,就是为了自动检查代码,保持一致的代码风格,从而保证代码质量. 这 ...

  8. java JDBC与MySQL 关于日间与日期

    //MySQL Date类型 -> java.sql.Date java.sql.Date d = new java.sql.Date(Calendar.getInstance().getTim ...

  9. Spring_总结_02_依赖注入

    一.前言 本文承接上一节:Spring_总结_01_Spring概述 在上一节中,我们了解了Spring的最根本使命.四大原则.六大模块以及Spring的生态. 这一节我们开始了解Spring的第二大 ...

  10. New Concept English three (57)

    28w/m 54errors I stopped to let the car cool off and to study the map. I had expected to be near my ...