# PROBLEM LINK

* Author:* Harsh Shah

*Dhrub Kumar*

**Tester:***Harsh Shah*

**Editorialist:**# DIFFICULTY:

Easy

# PREREQUISITES:

Implementation

# PROBLEM

Kichak and Bheem are competing for Rajkumari Indumati. Bheem needs to complete Kichak’s challenge in order to win. Kichak gives an array of N integers , such that it is the complete set of factors for a number X.

**This means that if X has N factors then array of size N would be given**. Bheem knows that Kichak is naughty so Kichak may have modified atmost 1 element in the array . Help Bheem Determine if the array was modified. If yes, print **“laddu”** (without the double-quotes) else print the number X corresponding to the array.

# EXPLANATION

The problem is vey straightforward to understand. Note how it is written that **complete set of factors** is mentioned in the problem statement. Also **atmost one** element is changed. This simply means that the array can be sorted , and then by maintaining two pointers L,R : where L points to the first index and R points to last index of the array initially , one can simply check whether the product of all pair of elements L,R {a_l * a_r = X} . If that is the case then print X. If the products dont correspond to the same number then this means that an element has been modified, thus the answer is “laddu”.

# SOLUTIONS:

## Setter's Solution

```
#include <bits/stdc++.h>
using namespace std;
int main()
{
long t;
cin>>t;
while(t--)
{
long n;
cin>>n;
vector<long>a(n);
for(long i=0;i<n;i++)
cin>>a[i];
sort(a.begin(),a.end());
long l=0,r=n-1,ans=a[l]*a[r],flag=1;
while(l<=r) {
if(a[l]*a[r]!=ans) {
cout<<"ladoo"<<"\n";
flag=0;
break;
}
l++;
r--;
}
if(flag==1)
cout<<ans<<"\n";
}
return 0;
}
```