题目传送门:http://ybt.ssoier.cn:8088/problem_show.php?pid=1165
【分析】
直接照抄题目公式,注意最后保留2位小数
【AC代码】
#include <bits/stdc++.h>
using namespace std;
double h(double n,double x){
//n等于0时的情况
if(n==0){
return 1;
}
//n等于1时的情况
if(n==1){
return 2*x;
}
//n大于1时的情况
if(n>1){
return 2*x*h(n-1,x)-2*(n-1)*h(n-2,x);
}
}
double n,x;
int main(int argc, char** argv) {
cin>>n>>x;
printf("%.2lf",h(n,x));
return 0;
}
给个赞再走吧