3 solutions

  • 3
    @ 2023-12-23 21:20:37
    #include<iostream>
    #define int long long
    using namespace std;
    int 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);
    }
    signed main(){
    	int n,x;cin>>n>>x;
    	cout<<h(n,x)<<".00";
    	return 0;
    }
    
    • 1
      @ 2024-2-19 11:35:45
      #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;
      }
      
      • -1
        @ 2023-11-16 13:32:25
        #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";
        }
        
        • 1

        Information

        ID
        651
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        5
        Tags
        # Submissions
        40
        Accepted
        18
        Uploaded By