Welcome to ZOJ Problem Sets Information Select Problem Runs Ranklist ZOJ Problem Set - 3504
P-norm

Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

In mathematics, the complex numbers are the extension of the real numbers obtained by adjoining an imaginary unit, denoted i, which satisfies: i2=-1. Every complex number can be written in the form a + bi or (a, b), where a and b are real numbers called the real part and the imaginary part of the complex number, respectively. The absolute value (or modulus or magnitude) of a complex number x = a + bi is defined as |x| = sqrt(a2 + b2).

In linear algebra, functional analysis and related areas of mathematics, a norm is a function that assigns a strictly positive length or size to all vectors in a vector space, other than the zero vector. P-norm is the most frequently used norm, let p >= 1 be a real number, x = (x1 x2 ... xn)T, ||x||p = (|x1|p + |x2|p + ... + |xn|p)1/p.

Given two vectors x and y in vector space over complex numbers, you job is to calculate ||x - y||p.

Input

Two vectors in vector space over complex number. The complexs are in notation (Re,Im), and the vectors are in form "x1 x2 ... xn" in a seperate line where 1 <= n <= 16 is the dimension of the vector and both a and b in xk = a + bi are in range [-16, 16]. Then a real number p specifies which p-norm we will use, p is in range [1, 16].

Each line contains no more than 256 characters, and the blanks only occur between adjacent complexes.

Output

A number: ||x - y||p. All answers with either an absolute or relative error of less than 1e-6 are considered correct.

Sample Input

```(4,0) (0,0)
(0,0) (0,-3)
2
(1,0) (0,1) (-1,0) (0,-1)
(1,0) (0,-1) (-1,0) (0,1)
1
(1.4142135623730950488016887242097,-1.4142135623730950488016887242097)
(0,0)
3.1415926535897932384626433832795
(1,1)
(0,0)
2.7182818284590452353602874713527
```

Sample Output

```5
4
2
1.4142135623730950488016887242097
```

Note

Acknowledgements to Wikipedia(http://en.wikipedia.org/wiki/Main_Page), the free encyclopedia, for providing background information.

Author: WU, Zejun
Submit    Status