You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
463 B
31 lines
463 B
#include<bits/stdc++.h>
|
|
using namespace std;
|
|
int main() {
|
|
long i,j, n,len=0,p;
|
|
long a[10000]= {0};
|
|
a[0]=1;
|
|
scanf("%ld",&n);
|
|
//一个数一个数的乘上来
|
|
for(i=1; i<=n; i++) {
|
|
//每一位都乘以i
|
|
for(j=0; j<=len; j++)
|
|
a[j]*=i;
|
|
p=0;
|
|
//遍历每一位
|
|
while(p<=len) {
|
|
//每次进一位
|
|
if(a[len]>9) {
|
|
len++;
|
|
}
|
|
a[p+1]+=a[p]/10;//取整进位
|
|
a[p]=a[p]%10; //取余保留
|
|
p++;
|
|
}
|
|
}
|
|
//输出结果
|
|
for(i=len; i>=0; i--)
|
|
printf("%ld",a[i]);
|
|
return 0;
|
|
}
|
|
|