HDU DFS

HDU DFSHDU DFS

#include<iostream>
using namespace std;
int main()
{
int a[11]; a[1] = 1; a[0] = 1;
for (int i = 2; i <= 10; i++)
a[i] = a[i - 1] * i;
for (int i = 1; i <= 3628800; i++)
{
int y = i, s = 0;
while (y > 0)
{
s = s + a[y % 10];
y = y / 10;
}
if (s == i) cout << i << endl;
}
return 0;
}

int 最大范围为十位数,假设每位都是九,10*9!=3628800 所以只需循环到3628800即可

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
  • 2021-05-21
  • 2021-08-26
  • 2021-12-13
  • 2022-02-20
  • 2021-07-15
猜你喜欢
  • 2021-11-04
  • 2021-06-23
  • 2021-08-03
  • 2021-05-23
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案