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;
}

最新文章

  1. 删除Tomcat服务及其它注意
  2. 《精通C#》委托与事件(10章)
  3. Idea 常用快捷键列表
  4. RelativeLayout_布局
  5. 二模 (8) day1
  6. ASP.NET MVC5写.php路由匹配时的问题 ASP.NET MVC 4 在 .NET 4.0 与.NET 4.5 的專案範本差異
  7. Unity3D - Animator Controller循环依赖
  8. hdu 5517 Triple(二维树状数组)
  9. 享元模式 FlyWeight 结构型 设计模式(十五)
  10. docker(五) 使用Docker Registry搭建镜像私服
  11. JS工具类
  12. (链表 双指针) leetcode 19. Remove Nth Node From End of List
  13. RocketMQ RPC
  14. java框架之Spring(2)-注解配置IOC&amp;AOP配置
  15. JAVA8之函数式接口
  16. 【Jmeter自学】Jmeter作用域(五)
  17. springMVC访问 WEB-INF 下的 jsp 和 html
  18. .NET 互联网技术简介
  19. test20181223
  20. exp,expdb,imp,impdb的使用

热门文章

  1. Mongodb 常用命令2
  2. 字符串转成整型(int)
  3. PHP防抓取数据curl 解决方法
  4. spring autowired还需要在xml中申明bean ?
  5. [Algorithm -- Dynamic programming] How Many Ways to Decode This Message?
  6. 外媒关注:中国版Twitter新浪微博推出微米对抗微信
  7. 【转】DNS查询过程
  8. [Swift A] - A Swift Tour
  9. 配置tomcat的session共享
  10. 创建你的第一个Android PHP应用