zoukankan      html  css  js  c++  java
  • 【Project Euler】4 第四题

    

    //A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
    //Find the largest palindrome made from the product of two 3-digit numbers.
          

      static void Main(string[] args)
            {
                int sum = 0;
                for (int i = 10; i < 1000; i++)
                {
                    for (int j = 10; j < 1000; j++)
                    {
                        sum = i * j;
                        if (sum / 100000 < 10)
                        {
                            int a = sum / 100000;
                            int b = (sum - a * 100000) / 10000;
                            int c = (sum - a * 100000 - b * 10000) / 1000;
                            int d = (sum - a * 100000 - b * 10000 - c * 1000) / 100;
                            int e = (sum - a * 100000 - b * 10000 - c * 1000 - d * 100) / 10;
                            int f = sum - a * 100000 - b * 10000 - c * 1000 - d * 100 - e * 10;
                            if (a == f && b == e && c == d)
                            {
                                if (sum > 900000)
                                {
                                    Console.WriteLine(sum);
                                }
                            }
                        }
                    }
                }
            }

    版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。

  • 相关阅读:
    DFS初级算法题练习 POJ2488 POJ3009 POJ1088
    分支限界法基础练习笔记
    PuyoPuyo DFS算法练习
    回溯法基础练习笔记
    java基础:I/O流学习笔记
    synchronized锁的各种用法及注意事项
    20.04搭建ROS2
    西安 交建交通科技 招聘信息
    在.NET2.0中使用LINQ
    sqlite+VS2010+EF
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4786198.html
Copyright © 2011-2022 走看看