#C14542. Sum of Squares of Unique Values
Sum of Squares of Unique Values
Sum of Squares of Unique Values
You are given a set of keys, each associated with a list of integers. For each key, compute the sum of the squares of the unique integers present in its list. The square of a number is expressed as .
The input begins with an integer , representing the number of keys. Following this, for each key, there are three inputs: a string key, an integer denoting the number of integers for that key, and a line of space-separated integers. If , the corresponding line for integers will be empty.
Output each key and its computed sum in the format key: result
on a separate line, preserving the order of the keys as given in the input.
inputFormat
The first line contains an integer , the number of keys. For each key, the following three lines are provided:
1. A string representing the key.
2. An integer indicating the number of integers in the list.
3. A line with space-separated integers (this line will be empty if is 0).
outputFormat
For each key, print a line in the format key: result
, where result
is the sum of the squares of all unique integers associated with that key.## sample
3
a
4
1 2 2 4
b
3
2 3 3
c
3
4 4 4
a: 21
b: 13
c: 16
</p>