Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Bohemian Rhapsody
Time Limit: 6000MSMemory Limit: 65536K
Total Submissions: 352Accepted: 40

Description

Is this the real life?
Or is this just fantasy?
Caught in a landslide
No escape from reality
Open your eyes
Look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go
A little high, little low
Anyway the wind blows, doesn't really matter to me…

There used to be a gambling called Bohemian Gambling. At the beginning of the game, a unit circle was drawn on a piece of paper. Then a point (x0, y0) in the circle and N (1 ≤ N ≤ 1000) vectors (Δxi, Δyi) were randomly chosen. At the i-th step of the gambling, a player draw a segment from the point (xi − 1, yi − 1) to (xi, yi), where xi = xi − 1 + Δxi and yi = yi − 1 + Δyi. If (xi, yi) was outside the circle or on its boundary, the game ended; otherwise the player would win some money and go on to the next step of the gambling until all N lines had been drawn.

As a predictor, Mercury had known all the vectors chosen for the gambling in advance, but he didn't know what the starting point would be. His clients asked him to find how much money they could win under average conditions, which meant the point would be chosen within the circle with uniformly distributed probability. They also wondered how much they could win if everything went the luckiest way. What would Mercury's reply to his clients be?

Input

The input consists of one or more data sets, followed by a last line containing a single zero. Each data set begins with a line containing an integer N, 1 ≤ N ≤ 500, which is the number of line segments that would be drawn. Then follow N lines, each containing two real numbers and an integer referring to Δxi, Δyi and the money that a player could win after the i-th step.

Output

For each test case your program should output two lines. The first line gives a real number which indicates the money a player can win under average conditions and the second line an integer number which indicates the maximum amount of money he could win. Refer to the sample output for details.

The real numbers should be rounded to three digits after the decimal point.

Sample Input

2 
1.0 1.0 100
-1.0 -1.0 50
0

Sample Output

Case 1:
The expected amount of money: 27.254
The maximum amount of money: 150

Source

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator