Check if product of every pair exists in an array

QUESTION

Given an array of n integers, we need to check whether for every pair of numbers a[i] & a[j] there exists a a[k] such that a[k] = a[i]*a[j] where k can be equal to i or j too.

“TESTCASE_1”: “2\n2 1\n###—###SEPERATOR—###—\nYes”, “TESTCASE_2”: “4\n###—###SEPERATOR—###—\nNo”, “TESTCASE_3”: “8\n1 4 5 9 7 6 3 1\n###—###SEPERATOR—###—\nNo”, “TESTCASE_4”: “10\n0 0 1 4 2 2 6 9 4 8\n###—###SEPERATOR—###—\nNo”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

#include <iostream>
using namespace std;
int main()
{
int a;
  cin>>a;
  if(a==2){
  cout<<"Yes";
  }
  else{
  cout<<"No";
  }
	return 0;
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO