Help me in solving MAKE_IT_ONE problem

My issue

not understanding the approach

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int L, R,n;
	    cin>>L>>R;
	    n=R-L+1;
	    int B[n];
	    for(int i=L; i<=R;i++)
	     { 
	       int B[n];
	       cin>>B[n];
          }
          for(int i=0; i<n; i++)
          {
              cout<<B[n]<<"";
          }
    }
}

Problem Link: Make It One Practice Coding Problem - CodeChef

@biru1152003
plzz refer my c++ code for better understanding

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int l,r;
	    cin>>l>>r;
	    int n=r-l+1;
	    if(n%2&&l%2==0)
	    {
	        cout<<-1;
	    }
	    else
	    {
	        if(n%2==0)
	        {
	        for(int i=l;i<=r;i+=2)
	        {
	            cout<<i+1<<" "<<i<<" ";
	        }
	        }
	        else
	        {
	            for(int i=l;i<=r-3;i+=2)
	            {
	                cout<<i+1<<" "<<i<<" ";
	            }
	            cout<<r-1<<" "<<r<<" "<<r-2;
	        }
	        
	    }
	    cout<<endl;
	}

}

#include<bits/stdc++.h>

using namespace std;

define int long long

signed main()
{
int m;
cin>>m;
while(m–)
{
int l,r;
cin>>l>>r;
if(__gcd(l,r)==1)
{
for(int t=l+1;t<=r;t++)
{
cout<<t<<" “;
}
cout<<l;
}
else if((r-l+1)%2==0)
{
for(int i=l;i<=r;i+=2)
{
cout<<i+1<<” “<<i<<” ";
}

    } 
    else if(l%2!=0 && r%2!=0) 
    { 
        cout<<l+1<<" "<<l+2<<" "<<l<<" "; 
        for(int i=l+3;i<=r;i+=2) 
        { 
            cout<<i+1<<" "<<i<<" "; 
        } 
    } 
    else 
    { 
        cout<<-1; 
    } 
    cout<<endl; 
} 

}
Correct code of MAKEITONE