Company: UBS_14aug
Difficulty: medium
Decrypt Code Lock Problem Description A code lock shows an array of integers codeSequence of length n , together with an integer maxValue . The locking system lets you change any element of the array to any integer from 1 to maxValue . Every changed element costs 1 unit. (inferred -- the source says "any integer less than or equal to maxValue"; values below 1 never help, because changing an element to 1 already makes it co-prime with everything.) Two numbers are co-prime if their greatest common divisor (GCD) is 1 . To unlock the repository, you must select one element of the array (after your changes) that is co-prime with every other element of the array. The lock's code is selected number - total modification cost Find the maximum possible lock code over all ways of changing elements and all choices of the selected element. Complete the function decryptCodeLock(codeSequence, maxValue) , which returns the maximum lock code as an integer. Input Format Read from standard input. n codeS