解题思路:
注意事项:
参考代码:
#include <iostream> #include <cstring> using namespace std; const int RN = 1e5 + 10; int a[RN], s[RN], n, len = RN - 1; void qj(int x) { for (int i = 0, k = 0; i < RN; ++i) { a[i] = a[i] * x + k; k = a[i] / 10; a[i] %= 10; } } void qh() { for (int i = 0, k = 0; i < RN; ++i) { s[i] += a[i] + k; k = s[i] / 10; s[i] %= 10; } } int main() { cin >> n; a[0] = s[0] = 1; for (int i = 2; i <= n; ++i) qj(i), qh(); while (!s[len--]); for (int i = len + 1; i >= 0; --i) cout << s[i]; return 0; }
0.0分
7 人评分