#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main()
{
vector<int>res;
int n;
cin>>n;
res.push_back(1);
int carry = 0;
for(int i = 1; i <= n; i++)
{
carry = 0;
int len = res.size();
for(int j = 0; j < len; j++)
{
int s = res[j]*i + carry;
res[j] = s%1000000; //1000000进制
carry = s/1000000;//逢1000000进1
}
if(carry > 0)
{
res.push_back(carry);
}
}
int len = res.size();
printf("%d",res[len-1]);//从后往前输入
for(int i = len - 2; i >= 0; i--)
{
printf("%06d",res[i]); //输出6位,不足六位用前导0补
}
cout<<endl;
return 0;
}
参考:
https://blog.csdn.net/qq_40977710/article/details/80499140?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task