TANKS - Tanks

Surprisingly, the king of the Quadruple Island Kingdom suddenly declares war on its neighbor country, the Utopia Land. After that, the King dispatches a large number of tanks for first attack. You, as the Defence Minister of Utopia Land, are certainly under mass of pressure. In order to defeat the enemy, you decide to use the new secret weapon: laser cannon. This kind of weapon is so powerful that can easily destroy any thing at a line in a moment, or course, including tanks.

However, because of some design flaw, you can use such weapon just once during the war. The only hope is that you can choose a good moment and right way to use it so that as many tanks as possible can be destroyed.

A tank can be described as a point whose coordinate is (Xi, Yi) on a 2D-plain with speed vector (VXi, VYi) per second. Starting at time 0, you can use your laser cannon at any position and in any direction at any INTEGER number of seconds after time 0. It is possible that some tanks will meet at the same point while moving, and they will not influence each other anyway.

Input

Multiple test cases. The number of test cases is no more than 10. For each test cases, The first line contains a single integer N (1 <= N <= 100) indicating the number of tanks. Then N lines are following that describing the tanks respectively. Each of them consists of four nonzero integer Xi, Yi, VXi, VYi separated by single spaces where |Xi|,|Yi| <= 100,000,000 and |VXi|,|VYi| <= 100 denoting the initial position of a tank and the speed vector. Input ends with N = 0.

Output

For each test case, output one line with a single integer indicating the largest number of tanks which can be destroyed by the laser cannon.

Note: Be careful when handling floating point errors.

Example

Input:
4
10 10 -1 -1
3 1 4 6
2 8 5 -1
1 3 1 4
0

Output:
3

Added by:Fudan University Problem Setters
Date:2011-09-08
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:ACM/ICPC Regionals, Shanghai 2011 Preliminary

hide comments
2012-05-19 19:14:34 :D
P.S. Time 0 is a valid moment for firing laser. It's a little unclear in the description.
2012-05-19 19:06:14 :D
I also failed to find anything easy about this task. Maybe not the hardest problem ever, but still very challenging. To put it on a scale, I would say harder than MCOCIR and any other "kinematics" problem I've done. But in whole "geometry" category, ECLIPSE was WAY harder.

There are some interesting precision issues, but I'm not sure to what extent they are validated in test cases. Maybe there is a better approach that works around it altogether.

That said it was really fun coming up with an algo and programming it. An easy recommendation.
2011-09-28 19:55:31 Shaka Shadows
Agree with @Problem Solver: hard problem, at least for me.
2011-09-14 03:33:49 Problem Solver
This task is super hard.

Re (by XilinX): This is just a problem of ICPC regionals PRELIMINARY contest.

Last edit: 2011-09-12 05:03:14
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.