QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 22

#5779. Scaled Triangle

Statistics

Problem

You are given two triangle-shaped pictures. The second picture is a possibly translated, rotated and scaled version of the first. The two triangles are placed on the table, with the second one placed completely inside (possibly touching the boundary of) the first one. The second triangle is always scaled by a factor that is strictly between 0 and 1.

You need to process the picture, and for that you need a point in the picture which overlaps with the same point of the scaled picture. If there is more than one solution, you can return any of them. If there are no solutions, print "No Solution" (without the quotes) for that test case.

Input

The first line of input gives the number of cases, N. Then for each test case, there will be two lines, each containing six space-separated integers -- the coordinates of one of the triangles -- in the format "x1 y1 x2 y2 x3 y3". The point (x1, y1) in the first triangle corresponds to the same corner of the picture as (x1, y1) in the second triangle, and similarly for (x2, y2) and (x3, y3).

Output

For each test case, output one line containing "Case #x: " followed two real numbers representing the coordinates of the overlapping point separated by one space character, or the string "No Solution". Answers with a relative or absolute error of at most 10-5 will be considered correct.

Limits

Time limit: 30 1 second(s) per test set.

Memory limit: 1GB.

1 ≤ N ≤ 10.

The coordinates of the points will be integer numbers between -10 000 and 10 000. The three points in each triangle will not be collinear.

Small dataset (Test set 1 - Visible; 9 Points)

All tests will contain isosceles right-angle triangles. (i.e., the triangle's angles will be 45 degrees, 45 degrees, and 90 degrees.)

Large dataset (Test set 2 - Hidden; 13 Points)

The triangles can have any shape.

Sample

2
0 0 0 2 2 0
0 0 0 1 1 0
10 0 0 10 0 0
3 3 1 1 3 1
Case #1: 0.000000 0.000000
Case #2: 2.692308 1.538462
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.