Company: Nokia_9march
Difficulty: medium
Product of pairs Problem Description You are given an array A of N integers and an integer K . Positions are numbered from 1, so the array is A_1, A_2, ..., A_N. Define a function f(i, j) as follows: f(i, j) = A_i x A_j if i < j and K | (j - i) f(i, j) = 0 otherwise Here K | (j - i) means that (j - i) is divisible by K . Calculate S = sum over i = 1..N of ( sum over j = i..N of f(i, j) ) Note that f(i, i) = 0 because the condition requires i < j, so every unordered pair of positions is counted at most once. Function Description Complete the function solve . It takes the following parameters and returns the value S for one test case: N : the size of the array K : the integer K from the statement A : the array of N integers (in code, the first element A_1 is stored at index 0) (inferred - the source editor's C stub declared a pointer/array return; the problem asks for a single number per test case, so solve returns one 64-bit integer.) Input Format The first line contains T , the n