#include <iostream> #include <vector> using namespace std; const int N = 1010; vector<int> f[N];//存储每个数的阶乘 vector<int> mul(vector<int>& A, int b) { int t = 0; vector<int> C; for (int i = 0; i < A.size(); i++) { t += A[i] * b; C.push_back(t % 10); t /= 10; //向高位进位 } while (t) { C.push_back(t % 10); t /= 10; } return C; } int main() { //预处理 f[0] = {1}; //0!=1 for (int i = 1; i <= 1000; i++) { f[i] = mul(f[i - 1], i); } //打表 int n; while (cin >> n) { for (int i = f[n].size() - 1; i >= 0; i--) cout << f[n][i]; cout << endl; } return 0; }