Question Name:Match makers

#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n,t;
	cin >> t;										// Reading input from STDIN
	    int gl[n],b[n];
	    for(int i=0;i<n;i++){
	    for(int i=0;i<n;i++){
	    int j=n-1,c=0;
	    for(int i=0;i<n;i++){
	        if(gl[i]% b[j] ==0 || b[j]% gl[i] == 0){
	       j = j-1; 
  return 0;  }
  • Problem Description
    Little Mojo owns a match making company, which even to her surprise is an extreme hit. She says that her success rate cannot be matched (Yeah, wordplay!) in the entire match-making industry. She follows an extremely simple algorithm to determine if two people are matches for each other. Her algorithm is not at all complex, and makes no sense – not even to her. But she uses it anyway.

    Let’s say say that on a given day she decides to select n people – that is, n boys and n girls. She gets the list of n boys and n girls in a random order initially. Then, she arranges the list of girls in ascending order on the basis of their height and boys in descending order of their heights. A girl Ai can be matched to a boy on the same index only, that is, Bi and no one else. Likewise, a girl standing on Ak can be only matched to a boy on the same index Bk and no one else.

    Now to determine if the pair would make an ideal pair, she checks if the modulo of their heights is 0, 

    i.e., Ai % Bi == 0 or Bi % Ai == 0. Given the number of boys and girls, and their respective heights in non-sorted order, determine the number of ideal pairs Mojo can find.

    Input format:
    The first line contains number of test cases. Then, the next line contains an integer, n, saying the number of boys and girls. The next line contains the height of girls, followed by the height of boys.

    Output format:
    Print the number of ideal pairs corresponding to every test case.

    1 <= Test Cases <= 10^2
    1 <= N <= 10^4 
    1 <= A i , B i <= 10^5
  • Test Case 1
    Input (stdin)1
    2 2 2
    2 2 2
    Expected Output3
  • Test Case 2
    Input (stdin)2
    1 6 9 12
    4 12 3 9
    2 2 2 2
    2 2 2 2
    Expected Output2

Leave a Reply

Your email address will not be published. Required fields are marked *

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.