这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2212
本来是想搜到DFS的题目做,结果看了这题的题目,才知道哥受骗了~~~
这题很水~~~因为结果就四个数:1,2,145,40585
所以~~~
AC代码:
// Author: Tanky Woo
// Blog: www.WuTianQi.com
// Problem: HDOJ 2212 DFS
#include
#include
using namespace std;
int main()
{
int arr[4] = {1, 2, 145, 40585};
for(int i=0; i<4; ++i)
cout << arr[i] << endl;
return 0;
}
/*
// 以下是先打表求出符合条件的数。
int fac(int n)
{
int i, ans=1;
for(i=1; i<=n; ++i)
ans*=i;
return ans;
}
int main()
{
int m, n, ans;
for(int i=1; i<=2147483647; ++i)
{
ans = 0;
int t = i;
while(t)
{
ans += fac(t%10);
t /= 10;
}
if(ans == i)
cout << i << endl;
}
}
*/