Algorithm · Pinduoduo · Hard
Problem For a given positive integer n, express n as the sum of perfect squares. The decomposition must contain the fewest perfect-square terms possible; printing only the minimum term count is not sufficient. Examples of perfect squares are 1, 4, 9, 16,.... Input Format The input consists of one positive integer, n. Output Format On the first line, output k, the smallest possible number of perfect squares in a decomposition of n. On the next line, output k space-separated…