题解 | #阶乘#
阶乘
https://www.nowcoder.com/practice/e58c8a55162d49c48115bdfa5da7da56
#include <iostream> using namespace std; int main() { int a; while (cin >> a) { // 注意 while 处理多个 case int y1 = 0, y2 = 0; for (int i = 1, tmp = 1; i <= a; ++i) { tmp *= i; if (i % 2) y1 += tmp; else y2 += tmp; } cout << y1 << ' ' << y2 << endl; } } // 64 位输出请用 printf("%lld")