(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 ...
随机推荐
- 电脑bios到底是什么?
没有哪个玩电脑的人不知道电脑bios,但是真正能明白bios是什么的?身边却没几个,甚至大多数电脑维修站的人员对bios也不够详细了解.一般人不去关心bios是因为它离我们的电脑真正使用仍有一段距离. ...
- ie浏览器css中的行为expression详解
CSS中的行为——expression (ie only) 最近对CSS中的行为比较感兴趣,虽然是不符合标准的也只有ie才能识别,但是他确实给css的功能扩展了不少.下面是摘自互联网上的文字和例子,因 ...
- Android---intent传递putStringArrayListExtra
Intent是Activity与Activity之间,Activity与Service之间传递参数的介质,使用Intent和Bundle在组件之间传递数据,而这两种通常实现的是Java基本对象类型和S ...
- 使用 IIS Manager 对 Windows Azure 网站进行远程管理
最近,我们为客户新增了使用 Windows自带的 IIS管理控制台管理 Azure网站的功能.IIS Manager支持 HTTP over SSL,提供到您的 Windows Azure 网站 ...
- AlertDialog弹出时背景明暗程度调整
今天有个需求是把弹出AlertDialog时的变暗的背景调整得不要那么暗. 一开始懒惰就直接百度中文搜索,结果找到的代码试了几次都不行. 后来老老实实开google.stackoverflow搜索,搜 ...
- hive 0.10 0.11新增特性综述
我们的hive版本升迁经历了0.7.1 -> 0.8.1 -> 0.9.0,并且线上shark所依赖的hive版本也停留在0.9.0上,在这些版本上有我们自己的bug fix patch和 ...
- Android清单文件具体解释(三)----应用程序的根节点<application>
<application>节点是AndroidManifest.xml文件里必须持有的一个节点,它包括在<manifest>节点下.通过<application>节 ...
- python命令行参数处理
使用argparse包来解析命令行参数: #/usr/bin/python #encoding=utf-8 import argparse parser = argparse.ArgumentPars ...
- git和GItHub的区别
git是一个版本控制工具.github是一个用git做版本控制的项目托管平台. 这有点类似于Wordpress和Wordpress.com的关系,前者是一个任何人都可以用的免费博客系统,后者是一个平台 ...
- ZOJ 1093 Monkey and Banana (LIS)解题报告
ZOJ 1093 Monkey and Banana (LIS)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...