Company: Texas instruments_SDE_Oncampus_24july
Difficulty: medium
Neel partied hard last night, forgetting there was a test in school today. The first question asked him to write down a set of "Special" numbers. Having no idea what a Special number was, he glanced at his neighbour's paper and managed to catch only a partial glimpse. Taking a chance, he guessed the remaining digits and submitted his answers. Naturally, he got the numbers wrong! For each number Neel wrote, determine how far off the nearest Special number is from his answer. A positive integer p is a Special number if dividing p by the sum of its digits yields a prime number. That division must be exact (no remainder), and the resulting quotient must be prime. For example, 18 is Special because 18 / (1 + 8) = 2 , and 2 is prime. For each number x in Neel's list, find the Special number s closest to x (measured by absolute difference |s - x| ), and report the signed offset s - x . Input Format The first line contains a single integer n , the count of numbers Neel wrot