传送门
正常写要用到【高精乘】
来看一下用Python打表大法怎么写
以N=30为例子,因为N=1000的数字太多了(实测证明打表N=1000再把所有数字复制上去,会因为代码长度过长而错误)
打开Python
code:
f=open(r'point1.txt','w') #存入文件point1.txt
i=2
last=1
n=int(input())
while i<=n:
f.write('"') #上引号
f.write(str(last))
f.write('",') #下引号与逗号
last*=i
i+=1
f.close() #关闭文件写入
输入30;
然后打开目录下的point1.txt;
复制到你的c代码里
code:
void Print_Factorial ( const int N )
{
if(N<0)
{
printf("Invalid input");
return ;
}
char str[][1000]={
"1","1","2","6","24","120","720","5040","40320","362880","3628800","39916800","479001600","6227020800","87178291200","1307674368000","20922789888000","355687428096000","6402373705728000","121645100408832000","2432902008176640000","51090942171709440000","1124000727777607680000","25852016738884976640000","620448401733239439360000","15511210043330985984000000","403291461126605635584000000","10888869450418352160768000000","304888344611713860501504000000","8841761993739701954543616000000"};
printf("%s",str[N]);
}
这样可以拿到15分,我觉得够了