1 //一个数组元素存14位,模拟即可 2 #include<cstdio> 3 int len = 0; 4 const long long m = 100000000000000; 5 long long a[10000]={1}; 6 7 void solve(long long x) 8 { 9 int add = 0; 10 for(int i=0; i<=len; ++i) 11 { 12 a[i] *= x; 13 a[i] += add; 14 add = a[i]/m; 15 a[i] %= m; 16 } 17 if(add > 0) 18 a[++len] = add; 19 } 20 21 int main() 22 { 23 int n; 24 scanf("%d",&n); 25 for(int i=n; i>0; --i) 26 solve((long long)i); 27 printf("%lld",a[len]); 28 for(int i=len-1; i>=0; --i) 29 printf("%014lld",a[i]); 30 printf("\n"); 31 }
时间: 2024-10-09 18:48:24