Finding the number of pairs from the given two arrays

Given two unsorted arrays A[i] & B[j], you need to find a "pair of numbers" satisfying the following:
       1. Arrange A[i] in Descending order
       2. Arrange B[j] in Ascending order
       3. For every ith element in array A[] & corresponding jth element in array B[] is said to be a "pair" if A[i] % B[j] == 0 or B[j] % A[i] == 0
    Now, count such pairs in the given two unsorted array of elements. Note, that the two arrays has same number of elements.

    Method 1:

    1. Sort the array A in Descending order
    2. Sort the array B in Ascending order
    3. set index i to 1, count = 0 and check whether A[i] % B[i] == 0 OR B[i] % A[i] == 0
    4. If the above condition satisfied, increment count else continue the loop until N, the number of elements in both of the arrays.
    Implementation:


    #include <stdio.h>
    
    /* Array size */
    #define MAX 1000000
    
    int main()
    {
        int B[MAX],G[MAX];
        int t,N,i,count,j,temp;
        
        /* Get the number of test cases from the user */
        scanf("%d",&t);
        
        while(t--)
        {
         
         /* Initialize the count as zero for every test case */
            count=0;
            
            /* Get the number of elements of the array */
            scanf("%d",&N);
            
            /* Get the elements of the array 1 */
            for(i=0;i<N;i++)
            {
               scanf("%d",&B[i]);
            }
            
            /* Get the elements of the array 2 */
            for(i=0;i<N;i++)
            {
               scanf("%d",&G[i]);
            }
            
            for(i=0;i<N;i++)
             for(j=i+1;j<N;j++)
             {
                 if(B[i]<B[j])
                  continue;
                 else
                 {
                     temp=B[i];
                     B[i]=B[j];
                     B[j]=temp;
                 }
             }
             
            for(i=0;i<N;i++)
             for(j=i+1;j<N;j++)
             {
                  if(G[i]>G[j])
                   continue;
                  else
                  {
                       temp=G[i];
                       G[i]=G[j];
                       G[j]=temp;
                  }
             }
            
            /* For every pair, increment the count */
            for(i=0;i<N;i++)
             if((B[i]%G[i])==0 || (G[i]%B[i])==0)
              count++;
            
            /* Print the count for every test case */
            printf("%d\n",count);
        }
        return 0;
    }