标签:思路 scanf 模拟 ram problem style 0ms names 整数
求10000以内n的阶乘。
100
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
思路:
模拟;
来,上代码:
#include<cstdio> using namespace std; int n,len,cur=1,s[500010]; int main() { scanf("%d",&n); len=0; s[0]=1; for(int v=2;v<=n;v++) { for(int i=0;i<=len;i++) s[i]*=v; cur=0; for(int i=0;i<=len;i++) { s[i]+=cur; cur=0; if(s[i]>9) cur+=s[i]/10; s[i]%=10; } while(cur>0) s[++len]=cur%10,cur/=10; } for(int i=len;i>=0;i--) putchar(s[i]+‘0‘); return 0; }
AC日记——求10000以内n的阶乘 openjudge 1.6 14
标签:思路 scanf 模拟 ram problem style 0ms names 整数
原文地址:http://www.cnblogs.com/IUUUUUUUskyyy/p/6142479.html