## Recent Interview Questions

More Questions »- 0of 0 votes
Given the width, height, start point, end point of the grid, and a list of points, you have to go through these points, ask how many paths are there from the start point to the end point, you can only move from (i, j) down and right.

- 0of 0 votes
The design of two functions, cyclecount (num, mod), cycleHistogram (low, high, mod). Probably, cyclecount (num, mod) do digits square sum mod operation. For example mod (12), mod (5) -> square (1) + square (2) mod 5 = 0 -> square (0) mod 5 = 0. Stop return 2. Finished digits square sum after take mod, mod and before the formation of a repetitive cycle. Return form the size before the cycle. CycleHistogram (low, high, mod) will give a [low, high]. Then return a histogram which stores the number of [low, high] inside the cycle size 1,2,3,4,5.

- 0of 0 votes
I was given this question recently in an interview.. There are three threads and a counter that will increase from 1 to 100. Catch is that thread 1 increments counter from 1 to 20. Thread 2 increments from 21 to 80. Thread 3 increments from 81 to 100.

- 0of 0 votes
Bob And GCD

Bob has an array A of size N. He doesn't like arrays in which the GCD of all elements is not K. He can perform multiple operations on an array. In each operation, he can either increase or decrease the value of an element by 1.

You have to tell the minimum operation Bob will take to make GCD of all elements in an array equal to KK ?

GCD here is Greatest Common Divisor.

Input Format

The first line contains T, the number of test cases.

For Each Testcase :

The first line contains 2 integers - K and N respectively, separated by a space.

The second line contains N integers, separated by a space, in order of their position in array.

Input Constraints

1≤T≤10

1≤N≤10^6

1≤A[i]≤10^6

1≤K≤10^6

Output Format

For each test case, print minimum number of operations Bob take in a new line.

Sample Input

1

5 3

4 5 6

Ans - 2

- 0of 0 votes
What is the benefit behind using Sbcglobal Email?