提交时间:2024-08-20 12:58:06
运行 ID: 168663
#include <bits/stdc++.h> using namespace std; int a[10005]; int main() { a[1] = 1; int c = 1, t = 0, tmp, n; cin >> n; if (n < 2) { cout << 1 << endl; return 0; } for (int i = 2; i <= n; i++) { for (int j = 1; j <= c; j++) { tmp = a[j] * i + t; a[j] = tmp % 10; t = tmp / 10; } while (t) { c++; a[c] = t % 10; t /= 10; } } for (int i = c; i > 0; i--) cout << a[i]; return 0; }