#include "stdafx.h" //求N! 0<=N<=1000 #include <iostream> using namespace std; #include <vector> int main() { vector<int> res(10000,0); int n; while (cin >> n) { //第0位标记位数 res[0] = 1; res[1] = 1; for (int i = 2; i <= n; ++i) { //每一位乘以i for (int j = 1; j <= res[0]; ++j) res[j] *= i; //调整每一位使得每一位为一位数 for (int j = 1; j <= res[0]; ++j) { if (res[j] >= 10) { res[j + 1] += (res[j] / 10); res[j] %= 10; //如果超出了res[0]位,则位数加1 if (j == res[0]) ++res[0]; } } } //输出 for (int i = res[0]; i > 0; --i) cout << res[i]; cout << endl; res.clear(); res.assign(10000,0); } return 0; }