(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 ...
随机推荐
- 当x含有偶数个1,返回1,否则为0。
题目描述: /* Return 1 when x contains an even number of 1s;0 otherwise. Assume W=32 */ int even_ones(uns ...
- .net mvc RazorEngine 字符串razor参数替换
在.net中有一个比较好的字符串参数替换的方案RazorEngine推荐大家看看原网站,然后做个小联系然后你就懂啦 首先呢得下载一个吧, vs中tools-> Library Paging Ma ...
- 读书笔记:js设计模式
面向过程编程,面向对象编程和函数式编程> 定义一个类方法1:function Anim(){ } Anim.prototype.start = function(){ .. };Anim.pro ...
- Delphi中三种方法获取Windows任务栏的高度
第一种:需要引用Windows单元 ShowMessage(IntToStr(GetSystemMetrics(SM_CYSCREEN)-GetSystemMetrics(SM_CYFULLSCREE ...
- Dojo baseurl
dojo.baseUrl baseUrl用来存储dojo.js存放 的跟目录,例如dojo.js的路径是“/web/scripts/dojo-1.3/dojo/dojo.js”则baseUrl为“/w ...
- [C++ Basic] Const 用法
定义: const 主要用于声明常量.当常量为对象时,对象值不可改变:当常量为指针时,该指针不可移动或重新赋值,但我们可以通过它去修改该指针的指向对象的值(前提是无需移动指针的修改).所谓的形参.返回 ...
- shell脚本内与mysql交互
一: mysqlCMD="mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASS}" crea ...
- c 计算Fibonacci数列:1,1,2,3,5,8,13……这题也是很经典。
输出数字序列2/,/,/,/,/,/...,输出个数由键盘输入.注意输入使用scanf输入 比如: 输入 3输出为 / / / 输入 输出为 / / / / #include<stdio.h&g ...
- 基础算法-查找:线性索引查找(I)
前面介绍的几种查找的算法都是基于数据有序的基础上进行的.但是在实际的应用中,很多数据集可能有惊人的数据量,面对这些海量的数据,要保证记录全部按照当中的某个关键字有序,其时间代价是非常昂贵的,所以这种数 ...
- Regex阅读笔记(一)之入门
在检查一行文本时,^代表一行的开始,$代表结束. 字符数组:[],在里面列举任意多个字符,可以匹配其中任意一个字符,字符组元字符'-'表示一个范围. ^$表示一个空行(没有任何字符,包括空白字符) [ ...