AcWing 3611. 阶乘
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 15;
int t,n,m,k,l,r,op,x,y;
int f[N];
bool flag;
void solve(){
f[1] = 1;
for(int i = 2;i<N;i++){
f[i]=f[i-1]*i;
}
cin>>n;
m = n%2 ? n : n-1;
n = n%2 ? n-1 : n;
int ans1 = 0;
int ans2 = 0;
for(int i = 1;i<=m;i+=2){
ans1 += f[i];
}
for(int i = 2;i<=n;i+=2){
ans2 += f[i];
}
cout<<ans1<<" "<<ans2;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}