bzoj#P2493. Share the Cakes

Share the Cakes

题目描述

Lunar Rose is a pure and kind girl who was born in a serene town on,with surprising coincidence,the Mid-autumn Festival that year.Therefore,on each of her birthday,she enjoys two cakes:for the birthday,and for the festival.
This year,Lunar would like to share the cakes with Jaddy,her boyfriend,on the nice day,isn’t it so romantic?What is the tragedy,Jaddy screwed up,again:
When Lunar placed two cakes on the table,she wanted Jaddy to cut the cakes for her so that they can both have half of the moon cake and so do the birthday cake.But Jaddy,as a lazy and impetuous guy,he just used a knife to cut them together easily,hence although the two cakes had been cut into two pieces each,they were not really uniform.What was worth?Lunar is a pretty perfectionist and suddenly quite angry with Jaddy due to his arbitrariness.Finally,Lunar chose to leave him.Stupid Jaddy!
Jaddy became extremely regretful and distressing.Lunar,a softhearted girl,does not have the heart to make him so painful so that she’d like to give Jaddy a chance to do it again.However,she set a strict limit for this task:Jaddy can only use one cut to separate the two cakes into equivalent halves.Evil Ms.Rose!
Both two cakes are convex polygons;the table and knife are both big enough and long enough thus can be considered as infinite planar and line.This way,tell Jaddy a strategy,which means a line,satisfying Lunar’s condition to cut cakes so that he can get her back.

输入格式

The first line of the input data is a positive integer TT indicating the number of test cases.Then TT cases follow.Each test case contains description of two cakes (polygons):each polygon begins with an integer nn which denotes the number of vertices,and then nn pairs of integers (x,yx,y) follows describing the coordinates of vertices counterclockwise.You may assume that each polygon has no more than 2020 vertices and all the coordinates are in range of [1000,1000][-1000,1000].Besides,the two polygons can be separated by a line,without touching on any points of the line.

输出格式

For each test case,output two real numbers kk and bb,leading by the case number,which means that Jaddy should cut the cakes along the line y=kx+by=k \ast x+b.It is guaranteed that both kk and bb among the answers are in range of [1×104,1×104][-1 \times 10^4,1 \times 10^4].See sample output for further details.Any answer with 10410^{-4} relative or absolute error is acceptable.

2
3
0 0
1 1
0 2
3
2 1
3 0
3 2
4
0 0
1 0
1 1
0 1
4
2 2
3 2
3 3
2 3
Case #1: 0 1
Case #2: 1 0

数据规模与约定

100%100\% 的数据满足:T100T \le 100

题目来源

Acm 2011 上海