Need Help in solving a Coding Contest Problem

Revision en1, by anm_coder007, 2018-12-07 06:55:51

A Prime Array is an array which doesn't contain a pair of numbers whose product is a square of an integer.

For eg [1,2,3] is a Prime Array but [1,2,4] is not.

Explanation : 1*4 gives 4 which is square of 2.

Given an array of integers determine the minimum number of operations to convert the array to a Prime array.

NOTE: An operation consists of either increasing or decreasing any element of the array by 1 but the element should always be positive.

Constraints: Length of array <=100

1 <=Each integer in array <=1000000

Eg. Array => [1,1,2]

Minimum operations to convert [1,1,2] to [1,2,3] is 2.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English anm_coder007 2018-12-07 06:55:51 668 Initial revision (published)