Help me in solving TPRODUCT problem

My issue

help to solve the problem

My code

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 1000000007;


int main() {
	// your code goes here
	while(1){
	   int h;
	   cin>>h;
	   if(h==0)break;
	   int n = (1<<h) -1;
	   vector<ll>v1(n);
	   for(int i=0;i<n;i++){
	       cin>>v1[i];
	   }
	   vector<ll>l(n,1);
	   vector<ll>r(n,1);
	   ll ans = 0;
	   for(int i = n-1;i>=0;i--){
	       if(i==0){
	          ll ans1 = (l[i]%mod*v1[i]%mod)%mod;
	          ll ans2 = (r[i]%mod * v1[i]%mod)%mod;
	          ans = max(ans1%mod,ans2%mod);
	           
	       }
	       else if(i&1){
	          ll ans1 = (l[i]%mod*v1[i]%mod)%mod;
	          ll ans2 = (r[i]%mod * v1[i]%mod)%mod;
	          l[(i)/2] = max(ans1,ans2);
	       }
	       else{
	          ll ans1 = (1LL*l[i]%mod*v1[i]%mod)%mod;
	          ll ans2 = (1LL*r[i]%mod * v1[i]%mod)%mod;
	          r[(i-1)/2] = max(ans1,ans2);
	       }
	   }
	   cout<<ans%mod<<endl;
	}

}

Problem Link: Tree Product Practice Coding Problem - CodeChef

@jaggadaku005
here plzz refer the following solution

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
	// your code goes here
	ios::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	const int mod=1e9+7;
	while(1)
	{
	    int n;
        cin >> n;
        int size = pow(2, n)-1;
        if(n == 0) break;
        
        vector<long long> v(size);
        vector<long double> comp;
        for(auto& el : v){
            cin >> el;
            comp.push_back(el);
        }
        
        for(int i = size - pow(2, n-1) - 1; i >= 0; --i){
    
            if(comp[2*i + 1] >= comp[2*i + 2]){
                v[i] = (v[i] * v[2*i + 1]) % mod;
                comp[i] *= comp[2*i + 1];
            }
            else{
                v[i] = (v[i] * v[2*i + 2]) % mod;
                comp[i] *= comp[2*i + 2];
            }
           
        }
        cout << v[0] << endl;
	}
	return 0;
}

can you explain why there is there is type of comp vector is long double.