POLYCODE - Polygon Encoder

Imagine an infinite table with rows and columns numbered using the natural numbers. The following figure shows a procedure to traverse such a table assigning a consecutive natural number to each table cell:

subir imagenes

This enumeration of cells can be used to represent complex data types using natural numbers:

  • A pair of natural numbers (i, j) is represented by the number corresponding to the cell in row i and column j. For instance, the pair (3,2) is represented by the natural number 17; this fact is noted by P2(3, 2) = 17.
  • The pair representation can be used to represent n-tuples. A triplet (a, b, c) is represented by P2(a, P2(b, c)). A 4-tuple (a, b, c, d) is represented by P2(a, P2(b, P2(c, d))). This procedure can be generalized for an arbitrary n:
    Pn(a1 ... an) = P2(a1, Pn−1(a2 ... an)),
    where Pn denotes the n-tuple representation function, n >= 2. For example P3(2, 0, 1) = 12.
  • A list of arbitrary length ha1 ... ani is represented by
    L(ha1 ... ani) = P2(n, Pn(a1 ... an)).

For example, L(h0, 1i) = 12.

The Association of Convex Makers (ACM) uses this clever enumeration scheme in a polygon representation system. The system can represent a polygon, defined by integer coordinates, using a natural number as follows: given a polygon defined by a vertex sequence h(x1, y1) ... (xn, yn)i assign the natural number:

L((hP2(x1, y1) ... P2(xn, yn))).

ACM needs a program that, given a natural numbers that represents a polygon, calculates the area of the polygon. It is guaranteed that the given polygon is a simple one, i.e. its sides do not intersect.

As an example of the problem, the triangle with vertices at (1, 1), (2, 0) and (0, 0) is codified with the number 2141. The area of this triangle is 1.

Input

The input consists of several test cases. Each test case is given in a single line of the input by a natural number representing a polygon. The end of the test cases is indicated with *.

Output

One line per test case, preserving the input order. Each output line contains a decimal number telling the area of the corresponding encoded polygon. Areas must be printed with 1 decimal place, truncating less significative decimal places.

Example

Input:
2141
206
157895330
*

Output:
1.0
0.5
1.0

Added by:Camilo Andrés Varela León
Date:2006-10-25
Time limit:3.117s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:XX Colombian National Programming ACM 2006

hide comments
2011-06-28 16:53:32 blashyrkh
What is input numbers limits?
2011-06-28 14:21:45 blashyrkh
To problem setter: my python solution (5308718) fails (NZEC). Can you tell me what happens?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.