Problem 34 Digit factorials (暴力)
来源:互联网 发布:网络性能指标 编辑:程序博客网 时间:2024/05/26 05:51
Digit factorials
Problem 34
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<bits/stdc++.h>using namespace std; int factorial(int n){ //return n==1 ? 1: n*factorial(n-1); int sum=1; for(int i=1;i<=n;i++) sum*=i; return sum;} int digit_factorial(int n){ int a=0,sum = 0; while (n!=0) { sum += factorial(n % 10); n /= 10; } return sum;} int main(){ vector<int> s; for (int i=3;i<=999999;i++) { if(digit_factorial(i) == i) { s.push_back(i); } } int sum=0; for (vector<int>::iterator it=s.begin();it!=s.end();it++) { sum += *it; } cout<<sum<<endl; return 0;}
1 0
- Problem 34 Digit factorials (暴力)
- (Problem 34)Digit factorials
- [Euler]Problem 34 - Digit factorials
- Problem 34—Digit factorials
- projecteuler---->problem=34----Digit factorials
- Project Euler:Problem 34 Digit factorials
- Problem 30 Digit fifth powers (暴力枚举)
- Problem 33 Digit cancelling fractions (暴力set+pair)
- No_33:Digit factorials
- 欧拉工程第34题:Digit factorials
- URAL 1083|Factorials!!!|暴力
- Backward Digit Sums (全排列 + 暴力)
- Digit Problem
- Problem 1106 Sum of Factorials
- Problem 1106 Sum of Factorials
- (Problem 33)Digit canceling fractions
- factorials
- Factorials
- 简单的登陆注册练习1 登陆
- mysql5.7+安装教程
- 最近的一些收获
- 33属地(2)79(3)117(4)
- 作用域和Servlet监听器
- Problem 34 Digit factorials (暴力)
- mysqldump命令
- Thymeleaf的使用
- writev碰上非阻塞IO--纯扯淡
- The type org.apache.commons.lang.exception.NestableRuntimeException cannot be resolved.
- AJAX下跨域的实现
- 编译过程、动静态库
- Ubuntu 16.04 上使用devstack部署openstack
- weka中文乱码永久完美解决!