(Problem 4)Largest palindrome product
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.
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdbool.h> bool palindromic(int n) //判断一个整数是否为回文数
{
char s[];
sprintf(s,"%d",n); //将整数n保存在字符数组s中
int i,len;
len=strlen(s);
for(i=; i<len/; i++)
{
if(s[i]!=s[len-i-])
return false;
}
return true;
} bool have_the_factor(int n) //判断是否含有两个3位数的因数
{
int s=;
int r,b;
while(s>)
{
if((n%s)== && ((n/s)> && (n/s)<))
return true;
s--;
}
return false;
} int main()
{
int i=;
while(i>)
{
if(palindromic(i) && have_the_factor(i))
{
printf("%d\n",i);
break;
}
i--;
}
return ;
}
Answer:
|
906609 |
(Problem 4)Largest palindrome product的更多相关文章
- (Problem 3)Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...
- 【欧拉计划4】Largest palindrome product
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/1371281760.html 原创:[欧 ...
- (Problem 41)Pandigital prime
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
- (Problem 33)Digit canceling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
- (Problem 73)Counting fractions in a range
Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...
- (Problem 42)Coded triangle numbers
The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangl ...
- (Problem 70)Totient permutation
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number ...
- (Problem 74)Digit factorial chains
The number 145 is well known for the property that the sum of the factorial of its digits is equal t ...
- (Problem 46)Goldbach's other conjecture
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...
随机推荐
- isinstance 和 issubclass
一.isinstance Python 中的isinstance函数 isinstance是Python中的一个内建函数 语法: isinstance(object, classinfo) 如果参数o ...
- selenium 学习笔记 ---新手学习记录(6) 问题总结(java)
1.查看网页的cookie信息 //查看cookie 登录后的cookie Set<Cookie> setcoke= driver.manage().getCookies(); for(C ...
- Linux必学的60个命令【转载】
Linux提供了大量的命令,利用它可以有效地完成大量的工 作,如磁盘操作.文件存 [转载地址]http://blog.chinaunix.net/uid-16728139-id-3154272.ht ...
- IOS 使用IOS6苹果地图
IOS应用程序中使用Map Kit API开发地图应用程序.其核心是MKMapView类的使用.我们可以设置地图显示方式,控制地图,可以在地图上添加标注. 1.显示地图 在Map Kit API中显示 ...
- BeanUtils复制属性
package xiao; public class User2 { private String name; private String password; public String getNa ...
- 帝国cms语句调用
帝国cms系统,灵动标签,有着非常强大的数据调用功能.这里为广大菜鸟站长普及一下. 我们来看这段代码. [e:loop={,,}] <li>·<a target="_bla ...
- kinect for windows - SkeletonBasics-D2D详解之二
首先看骨骼追踪例子代码的结构:
- java中常见的单例模式详解
很多求职者在面试过程中都被问到了单例模式,最常见的问题,比如,每种单例模式的区别是什么?哪些模式是线程安全的?你们项目里用的哪种单例模式?原来没有注意这个问题,回来赶紧打开项目查看了一下代码,才发现我 ...
- sql中select语句的逻辑执行顺序
下面是SELECT语句的逻辑执行顺序: FROMONJOINWHEREGROUP BYWITH CUBE or WITH ROLLUPHAVINGSELECTDISTINCTORDER BYTOP M ...
- poj 1503 Integer Inquiry (高精度运算)
题目链接:http://poj.org/problem?id=1503 思路分析: 基本的高精度问题,使用字符数组存储然后处理即可. 代码如下: #include <iostream> # ...