#include <iostream> #include <vector> using namespace std; int jc(int a) //计算一个数的阶乘,采用递归 { if (a == 1) { return a; } return (a * jc(a-1)); } int main() { int a; while (cin >> a) { // 注意 while 处理多个 case vector<int> ji; //存储奇数子项阶乘 vector<int> ou; //存储偶数子项阶乘 int temp = a; if(a % 2 == 0) { temp--; while (temp > 0) { ji.push_back(jc(temp)); //存入奇数待求和序列 temp -= 2; } temp = a; while (temp > 0) { ou.push_back(jc(temp));//存入偶数待求和序列 temp -= 2; } }else { while(temp > 0) { ji.push_back(jc(temp)); temp -= 2; } temp = a; temp --; while (temp > 0) { ou.push_back(jc(temp)); temp -= 2; } } temp = 0; for (int i = 0; i < ji.size(); i++) { temp += ji[i]; //求和并输出 } cout << temp; cout << " "; temp = 0; for (int i = 0; i < ou.size(); i++) { temp += ou[i]; //求和并输出 } cout << temp; cout << endl; } } // 64 位输出请用 printf("%lld")