Help me in solving STRNG problem

My issue

output is coming wrong

My code

``````#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
int t,v;
cin>>t;
while(t--){

int n=0;cin>>n;
vector<int>v(n);
for(int i=0;i<n;++i)
{
cin>>v[i];
}
vector<int>prefix(n);
prefix[0]=v[0];
for(int i=1;i<n;++i)
{
prefix[i]=(prefix[i-1],v[i]);
}
vector<int>suffix(n);
suffix[n-1]=v[n-1];
for(int i=n-2;i>=0;--i)
{
suffix[i]=(suffix[i+1],v[i]);
}
int strong =0;
for(int i=0;i<n;++i)
{
if(i==0 && suffix[i]>i){
strong++;

}
else if((prefix[i-1],suffix[i+1])>1)
{
strong++;
}
}
cout<<strong<<'\n';
}
}

``````

Learning course: Number theory
Problem Link: CodeChef: Practical coding for everyone

@krajgor23
your logic is correct but implementation is wrong .
plzz refer the following solution for better understanding.

``````#include <bits/stdc++.h>

using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
int n,i,x;
vector<int> v;
cin>>n;
for(i=0;i<n;i++)
{
cin>>x;
v.push_back(x);
}
int gcd;
gcd=v[0];
vector<int> pre;
for(i=0;i<n;i++)
{
gcd=__gcd(gcd,v[i]);
pre.push_back(gcd);
}
gcd=v[n-1];
vector<int> suf;
for(i=n-1;i>=0;i--)
{
gcd=__gcd(gcd,v[i]);
suf.push_back(gcd);
}
reverse(suf.begin(),suf.end());
int res=0;
for(i=1;i<n-1;i++)
{
if(__gcd(pre[i-1],suf[i+1])!=1)
{
res++;
}
}
if(pre[n-2]!=1)
{
res++;
}
if(suf[1]!=1)
{
res++;
}
cout<<res<<endl;
}
return 0;
}
``````