自我感觉没问题,但是过不了,求大佬帮助
查看原帖
自我感觉没问题,但是过不了,求大佬帮助
834864
2_202240210224楼主2024/3/17 15:51
#include <bits/stdc++.h>
using namespace std;

int f(int n, int x) {
    if(n == 0) return 0;
    else if(n == 1) return 2 * x;
    else {
        return 2 * x * f(n-1,x) - 2 * (n-1) * f(n-2,x);
    }
}

int main() {
    int n,x;
    cin>>n>>x;
    cout<<f(n, x);
    return 0;
}

2024/3/17 15:51
加载中...