您的位置:首页 > 其它

hdu 1042 N!

2015-07-27 17:25 323 查看
本题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042

AC代码:

#include<stdio.h>
#include<string.h>
int str[110000];
int main()
{
int n,i,j,k,count,temp;
while(scanf("%d",&n)!=EOF)
{
memset(str,0,sizeof(str));
count=1;
str[0]=1;
for(i=1;i<=n;i++)
{
k=0;
for(j=0;j<count;j++)
{
temp=str[j]*i+k;
str[j]=temp%10;
k=temp/10;
if(k!=0&&j==count-1)
{
count++;
}
}
}
for(i=j;;i--)
if(str[i]!=0) break;
for(;i>=0;i--)
printf("%d",str[i]);
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: