# Help me in solving EQPAIR problem

### My issue

plz debug my code…

### My code

``````#include <bits/stdc++.h>
using namespace std;
#define ll long long int

ll gcd(ll a,ll b){
if(a==b) return a;
if(a>b){
if(a>0 && b==0){
return a;
}
else{
return  gcd(a%b,b);}
}
else {
if(a<b ){
if(b>0 && a==0){
return b;}
}
else{
return  gcd(a,b%a); }

}
}
ll lcm(ll a,ll b){

ll e=(a*b)/gcd(a,b);
return e;}

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);

int t;
cin>>t;
while(t--){
ll n,k=0;
cin>>n;
ll h[n];
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(gcd(h[i],h[j])==lcm(h[i],h[j])){
k++;
}
}
}
cout<<k<<endl;
}

return 0;
}

``````

Problem Link: EQPAIR Problem - CodeChef

You haven’t taken the input of h[n] array

I corrected but after that it show run time error .
Else i see another submissions but they using pnc
, i don’t understand that part why they are using pnc.
Plz explain my doubt

you can refer this solution

``````#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++)
cin>>a[i];

map<ll,ll>mp;
for(ll i=0;i<n;i++){
mp[a[i]]++;

}

ll sum=0;
for(auto it:mp){
sum+=((it.second*(it.second-1))/2);
}
cout<<sum<<endl;

}
return 0;
}

``````

They are using pnc because you have to count total number of pairs that can be formed using same elements.

As LCM * HCF = m * n
m and n are two different elements.

pnc will give (n*(n-1))/2 as a result. So, you can directly use this.