Problem A
Complex Numbers
Input: standard input
Output: standard output
Time Limit: 2 seconds
Numbers of the form a±bi are
called complex numbers (Where i = √(-1)).
In this problem you will have to find all the values of (a±bi)1/n .
Input
The input file contains several lines of input. Each line has two parts. The first part will contain a complex number of the form a±bi and the second part will contain an integer n (0<n<=100). Here a and b are integer numbers and 0<=|a|, |b|<100. Input is terminated by end of file.
Output
For each line of input you should produce n+2 lines of output. The description of output for each line of input is given in the next paragraph:
First line contains the case number as shown in the sample output. Next n lines should contain the n-th roots of the input complex number. The printed complex numbers should be of the form x±yi, where x and y are floating point numbers rounded upto three digits after the decimal point. Note that there is no space between the operators and operands. The roots are sorted according to descending order of their real part and then according to the descending order of their imaginary part. When the printed value of x or y is 0.000, it should be interpreted as positive zero. So you should never print something like “-0.000”. After all these outputs print a blank line.
Sample Input:
3+4i 2
5-4i 3
Sample
Output:
Case 1:
2.000+1.000i
-2.000-1.000i
Case 2:
1.810-0.414i
-0.546+1.775i
-1.264-1.361i
(Regionals
2002 Warm-up Contest, Problem setter: Shahriar Manzoor)