Pairwise Sum and Divide

  • + 0 comments

    Note that a,b ≥ 1, so a+b/ab quickly approaches 0. Because we take the floor of the function only a few value pairs will give non-0 results. Experimenting around, you'll see that 1,1 gives 1+1/1*1 = 2/1 = 2 and 1,n | n≥2, yields 1+n/n, which will yield 1 for all values n. Next, 2,2 yields 4/4 = 1, and 2,n yields 2+n/2n = 0 for n ≥ 3.

    So, we need 2*nP2 | n = # of 1s, which is 2*n!/(n-2)!2! = 2n(n-1)/2 = n(n-1)

    Also, for each 1, each non-1 will yield 1, so with m 1s and n other numbers, we'll need n*m (note than n = len(a)-m).

    Lastly, we'll need nP2 | n = # of 2s, which, similar to above = n(n-1)/2

    As for coding, I reccommend creating a counter (you could just do an array [m,n], then calculate the necessary values from that and total them.