You are given two arrays each with N elements. Elements of each arrays follow a particular generator dependent on factors a,b and c . You have to choose on element from both the arrays such that if you chose ith element from one array and jth element from another array then i should not be equal to j and sum of the both elements should be minimum.
Remember that the generator code is language independent. Please make relevant changes as per the language you use
A[1] = a*c;
for(i=2 ; i<=n ; i++)
{
A[i] = A[i-1]*a*b*c + A[i-1]*a*b + A[i-1]*a*c;
A[i] = A[i]%1000000007;
}
B[1] = b*c;
for(i=2 ; i<=n ; i++)
{
B[i] = B[i-1]*b*c*a + B[i-1]*b*a + B[i-1]*b*c;
B[i] = B[i]%1000000007;
}
InputThe arrays generated are 1 3 9 and 1 3 9, So answer will be 4