• + 0 comments

    canConstruct Function:

    This function takes an array of non-negative integers (numbers) and its size (n) as parameters. It initializes an array count to count the frequency of each digit from 0 to 9. It then iterates through each number in the array, updating the digit frequencies. After counting, it calculates the sum of digits weighted by their frequencies. It returns "Yes" if the sum is divisible by 3, indicating that a new integer can be constructed, and "No" otherwise. main Function:

    It starts by inputting the number of queries (q). For each query, it takes the number of non-negative integers (n) and the integers themselves. It calls the canConstruct function for each set of numbers and prints the result. The program checks if it's possible to construct a new integer from each set of non-negative integers such that the resulting number is divisible by 3. The result for each query is printed.