Project Euler problem 38
来源:互联网 发布:儿童 编程 编辑:程序博客网 时间:2024/04/28 00:40
这题主要看观察能力
他要找最大的。
就得比题目给的那个要大
给的是9开头的。
所以呢。要找的肯定也是9开头的。
首先看90几行不,乘1乘2乘3后发现位数不能到9位
再看900多
再看9000多
发现9000多有可能行
乘以2后是5位数
然后凑一块就是个9位数
然后枚举9000多就行了
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <vector>#include <queue>#include <set>#include <stack>#include <cmath>#include <map>#include <ctime>#define MAXN 111111#define INF 100000007using namespace std;int v[11];bool isok(){ if(v[0]) return 0; for(int i = 1; i <= 9; i++) if(v[i] != 1) return 0; return 1;}int main(){ for(int i = 9876; i >= 9123; i--) { memset(v, 0, sizeof(v)); int ti = i; while(ti) { v[ti % 10]++; ti /= 10; } ti = i * 2; while(ti) { v[ti % 10]++; ti /= 10; } if(isok()) { printf("%d%d\n", i, i * 2); break; } } return 0;}
- Project Euler problem 38
- Project Euler:Problem 38 Pandigital multiples
- Euler Project Problem 6
- project euler problem 11
- Project Euler Problem 81
- Project Euler Problem 60
- Project Euler Problem 59
- Project Euler Problem 58
- Project Euler Problem 57
- Project Euler Problem 16
- Project Euler Problem 30
- Project Euler Problem 31
- Project Euler Problem 32
- Project Euler Problem 14
- Project Euler Problem 15
- Project Euler Problem 17
- Project Euler - Problem 18
- Project Euler - Problem 67
- linux 网络配置和问题解决
- Linux(Ubuntu12.04)环境的Nexus搭建
- opencv直方图使用学习
- c++工作宝贵经验呀,我去。。。。
- C++堆和栈详细介绍
- Project Euler problem 38
- jQuery Ajax 请求
- 回收VMWare虚拟机占用的磁盘空间
- SIGSEGV和SIGBUS
- break和continue的区别
- 最大流poj1273
- 析构函数
- jquery 克隆clone()使用实例
- 2.内存管理之objective-c