#K80622. Transformed Dictionary Product
Transformed Dictionary Product
Transformed Dictionary Product
This problem requires you to transform an input dictionary of string keys and integer values. For each key, compute its reverse as the new key. The corresponding value in the new dictionary is the product of all integers in the input except the one associated with that key. In mathematical terms, if the product of all values is \(P = \prod_{i=1}^{n} a_i\), then for each key with value \(a_k\), the new value is \(\frac{P}{a_k}\) (when \(n > 1\)). If the dictionary contains only a single key, the output value is defined as 1. An empty dictionary should result in an output of {}.
inputFormat
The input is read from standard input. The first line contains an integer \(n\) representing the number of key-value pairs. Each of the following \(n\) lines contains a string (the key) and an integer (the corresponding value), separated by a space.
outputFormat
If \(n > 0\), the program should output \(n\) lines. Each line contains the reversed key and the computed product (i.e. the product of all values except the one corresponding to that key), separated by a space. In the special case where \(n = 0\), output a single line containing {}.
## sample3
apple 2
banana 3
cherry 4
elppa 12
ananab 8
yrrehc 6
</p>