(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 ...
随机推荐
- 05-C语言运算符
目录: 一.进制转换 二.常量 三.sizeof 四.运算符 五.赋值运算符 六.自增减运算符 七.关系运算符 八.逻辑运算符 九.取址寻址运算符 回到顶部 一.进制转换 1 进制转换是人们利用符号来 ...
- float编码杂谈
浮点数的编码转换采用的是IEEE规定的编码标准,float和double 这两种类型的数据的转换原理相同,但是由于范围不一样,编码方式有些区别.IEEE规定的编码会将一个浮点数转换为二进制数.以科学计 ...
- ASP.NET jQuery 随笔 使用jQuery UI的Autocomplete方法实现文本框的自动搜索填充功能
首先当然是去下载JQuery UI ,这里这里是下载地址http://jqueryui.com/ 第一步是点击这里 第二步选择你想要下载的主题进行下载 我这里是选择的cupertino主题包 点击圆圈 ...
- Loggerly技术架构
https://www.loggly.com/blog/topic/log-management-technology/
- 用于展现图表的50种JavaScript库
在很多项目中都会有在前端展现数据图表的需求,而在开发过程中,开发者往往会使用一些JavaScript库,从而更有效地达到想要的目标.最近,TechSlide上的一篇文章总结了50种用于展现图表的Jav ...
- HDU 1720 A+B Coming
#include <string> #include <cstdio> #include <iostream> using namespace std; int c ...
- C++之sort函数
C++中的sort函数可以直接完美地取代Pas中十多行的快排代码,在这里,总结一下sort函数的用法: 首先是不加参数的情况: #include<cstdio> #include<a ...
- 10003 Cutting Sticks(区间dp)
Cutting Sticks You have to cut a wood stick into pieces. The most affordable company, The Analog ...
- Querying Microsoft SQL Server 2012 读书笔记:查询和管理XML数据 2 -使用XQuery 查询XML数据
XQuery 是一个浏览/返回XML实例的标准语言. 它比老的只能简单处理节点的XPath表达式更丰富. 你可以同XPath一样使用.或是遍历所有节点,塑造XML实例的返回等. 作为一个查询语言, 你 ...
- linux串口编程(c)
//linux c: 串口设置//串口操作无非以下几个://1 打开 //2 设置串口属性//3 read write //struct termios能够 ...