3 solutions
- 1
Information
- ID
- 651
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 40
- Accepted
- 18
- Uploaded By
#include<bits/stdc++.h>
using namespace std;
double h (int n,int x) {
if (n==0) {
return 1;
} else if (n==1) {
return 2*x;
} else {
return 2*x*h(n-1,x)-2*(n-1)*h(n-2,x);
}
}
int main () {
int n,x; cin >> n >> x;
printf("%.2lf",h(n,x));
return 0;
}
#include<iostream>
using namespace std;
long long h(long long n,long long x){
if(n==0)return 1;
else if(n==1)return 2*x;
else return 2*x*h(n-1,x)-2*(n-1)*h(n-2,x);
}
int main(){
long long n,x;
cin
>>n
>>x;
cout
<<h(n,x)
<<".00";
}
By signing up a ZXOJ universal account, you can submit code and join discussions in all online judging services provided by us.