Project Euler:Problem 34 Digit factorials
来源:互联网 发布:一级域名绑定博客 编辑:程序博客网 时间:2024/05/29 10:04
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
#include <iostream>#include <vector>using namespace std;vector<int> int_vet(int a){vector<int> res;while (a){int tmp = a % 10;a /= 10;res.push_back(tmp);}return res;}int a[10] = { 0 };void p(){a[0] = 1;a[1] = 1;for (int i = 2; i <= 9; i++)a[i] = a[i - 1] * i;}int main(){p();int res = 0;for (int i = 3; i < 10000000; i++){int count = 0;vector<int> num = int_vet(i);for (int j = 0; j < num.size(); j++)count += a[num[j]];if (count == i)res += count;}cout << res << endl;system("pause");return 0;}
0 0
- Project Euler:Problem 34 Digit factorials
- [Euler]Problem 34 - Digit factorials
- (Problem 34)Digit factorials
- Problem 34—Digit factorials
- Project Euler:Problem 16 Power digit sum
- Project Euler:Problem 20 Factorial digit sum
- Project Euler:Problem 30 Digit fifth powers
- Project Euler:Problem 33 Digit cancelling fractions
- Project Euler:Problem 51 Prime digit replacements
- Project Euler:Problem 56 Powerful digit sum
- Project Euler:Problem 63 Powerful digit counts
- Project Euler:Problem 74 Digit factorial chains
- Project Euler:Problem 90 Cube digit pairs
- Project Euler:Problem 92 Square digit chains
- Project Euler Problem 16 Power digit sum
- Project Euler Problem 20 Factorial digit sum
- Project Euler Problem 92 Square digit chains
- projecteuler---->problem=34----Digit factorials
- fileinput模块:读取,替换文本内容
- 非ART黑屏处理建议
- Java文档上传问题设计
- c语言-数组名字是指向数组第一个元素的指针
- 疯狂Java学习笔记(72)-----------大话程序员面试
- Project Euler:Problem 34 Digit factorials
- JNI学习积累之二 ---- 数据类型映射、域描述符说明
- 中兴手机使用webview出现NPObject deleted问题
- LeetCode: Remove Linked List Elements
- asp.net代码操作xml示例
- GCJ 2015R2(Pegman-试出来)
- iOS5中UIViewController的新方法 addChildViewController
- Sky数
- UML类图几种关系的总结