[FZH] 出个小题,大家娱乐下

dhyang dhyang555在gmail.com
星期二 四月 13 16:24:37 UTC 2010


在 2010-04-13二的 23:42 +1000,Caius 'kaio' Chance写道:
> 你們閒得玩解題,可以去挑戰那些算法網站。
这个结果是吓人的。
[yang在fedora test]$ vi 100.cpp
[yang在fedora test]$ g++ -o 100 100.cpp 
[yang在fedora test]$ ./100
the sum is:  3.10E+93     
[yang在fedora test]$ 


算法如下,正确性是no warranty的, just for fun……
#define OK 1
#define ERROR 0
#define FUCK -1
#include <stdio.h>
#include <math.h>
double fac(int x)
{
if(x<0) return ERROR;
else if(x==0||x==1) return 1;
else return (x*fac(x-1));
return FUCK; 
}
double Array(int x,int y)
{
return (fac(y)/fac(y-x));
}
int main()
{double sum;
for(int i=0;i<=50;++i)
sum+=Array(i,i+50);
printf("the sum is:%-13.2E\n",sum);
return OK;
}




关于邮件列表 Chinese 的更多信息