project euler 4
来源:互联网 发布:简单软件的c语言程序 编辑:程序博客网 时间:2024/06/07 17:20
题目:
https://projecteuler.net/problem=4
题意:
Largest palindrome product
Problem 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.
求两个三位数的乘积中最大的回文数字
思路:
直接枚举两个三位数,判断它们的乘积是不是回文数,取乘积是回文数的最大值
代码:
#include <bits/stdc++.h>using namespace std;bool isPalindrome(int x){ int rx = 0, cx = x; while(cx) { rx = rx * 10 + cx % 10; cx /= 10; } return x == rx;}int main(){ int ans = 0; for(int i = 100; i < 1000; ++i) for(int j = 100; j < 1000; ++j) { if(isPalindrome(i * j)) ans = max(ans, i * j); } printf("%d\n", ans); return 0;}
阅读全文
0 0
- Project Euler - Problem 4
- Project Euler problem 4
- Project Euler 4
- Project Euler 4
- Project Euler - 4
- Project Euler Problem 4
- Project Euler Question 4
- Project Euler Problem 4
- project euler 4
- 【Project Euler】4 第四题
- Project Euler
- project euler
- Project Euler
- 【Project Euler】【Problem 4】Largest palindrome product
- Project Euler Problem 4: Largest palindrome product
- Project Euler .net
- Project Euler 0
- Project Euler 1-6
- scrapy安装错误:Microsoft Visual C++ 14.0 is required...
- js实现点击按钮出现输入框本地修改文字内容功能
- c/c++面试题
- zookeeper 集群安装
- Apache Tiles 学习(二)、Java Web应用中使用Apache Tiles
- project euler 4
- 做项目时后端处理json数据
- 微信小程序—swiper(滑块视图容器)
- Python代码中的捕捉性能-CPU分析(Python脚本)
- 抽象类和接口
- SpringMVC中@Controller和@RequestMapping用法和其他常用注解
- 【算法】算法分析与设计的基本方法
- 去掉EditText的默认焦点
- 用IOT的思维来管理我们的查看我们重要业务的服务器健康状态-Azure配置篇!