//土尔逊Torson 编写于2023/05/22
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
const int MAXN = 10000;
struct BigInteger083 { //定义大数
int digit[MAXN];
int length;
BigInteger083();
BigInteger083(int x);
BigInteger083 operator=(string str);
BigInteger083 operator*(const BigInteger083& b);
friend istream& operator>>(istream& in, BigInteger083& x);
friend ostream& operator<<(ostream& out, const BigInteger083& x);
};
istream& operator >> (istream& in, BigInteger083& x) { //定义输入操作符
string str;
in >> str;
x = str; //使用本程序定义的 赋值操作符 ( = )
return in;
}
ostream& operator << (ostream& out, const BigInteger083& x) { //定义输出操作符
for (int i = x.length - 1; i >= 0; --i) {
out << x.digit[i];
}
return out;
}
BigInteger083::BigInteger083() { //定义大数重载
memset(digit, 0, sizeof(digit));
length = 0;
}
BigInteger083::BigInteger083(int x) { //定义大数 int 重载
memset(digit, 0, sizeof(digit));
length = 0;
if (x == 0) {
digit[length++] = x;
}
while (x != 0) {
digit[length++] = x % 10;
x /= 10;
}
}
BigInteger083 BigInteger083::operator=(string str) { //定义赋值操作符 ( = )
memset(digit, 0, sizeof(digit));
length = str.size();
for (int i = 0; i < length; ++i) {
digit[i] = str[length - i - 1] - '0';
}
return *this;
}
BigInteger083 BigInteger083::operator*(const BigInteger083& b) { //定义乘法操作符 ( * )
BigInteger083 answer;
answer.length = length + b.length;
for (int i = 0; i < length; ++i) { //用传统纸上手算乘法的方式计算,暂时不进位
for (int j = 0; j < b.length; ++j) {
answer.digit[i + j] += digit[i] * b.digit[j];
}
}
for (int i = 0; i < answer.length; ++i) { //处理进位,进行进位运算
answer.digit[i + 1] += answer.digit[i] / 10;
answer.digit[i] %= 10;
}
//注意 answer.digit[answer.length - 1] 等于 0 时 就是第 answer.digit[] 的 第 answer.length 个数 等于 0
while (answer.digit[answer.length - 1] == 0 && answer.length > 1) { //因为是逆置的大数,所以从后向前去掉多余的 0
answer.length--; //和重置长度参数
}
return answer;
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
BigInteger083 Q(1);
for (int i = 1; i <= n; ++i) { //计算N的阶乘,从小数往大数乘法计算
Q = Q * BigInteger083(i);
}
cout << Q << endl; //用定义的输出操作符输出
}
system("pause");
return EXIT_SUCCESS;
}
// 64 位输出请用 printf("%lld")