ЗАДАЧА 3: Ship Damage

Задача 1. Problem-Ship Damage

Условие:
Inside the sea (a standard Cartesian /rectangular/ coordinate system) we are given a ship S (a rectangle whose sides are parallel to the coordinate axes), a horizontal line H (the horizon) and three catapults, given as coordinates C1, C2 and C3 that will be used to fire the ship. When the attack starts, each catapult hits a projectile exactly into the positions that are symmetrical to C1, C2 and C3 with respect to the horizon H. When a projectile hits some of the corners of the ship, it causes a damage of 25%, when it hits some of the sides of the ship, the damage caused is 50% and when it hits the internal body of the ship, the damage is 100%. When the projectile hit outside of the ship, there is no damage. The total damage is sum of the separate damages and can exceed 100%.
At the figure below a sea, a ship S, a line H, three points C1, C2 and C3 and their hit positions are shown:
Practical exam_CSharp_Variant 1_a

Your task is to write a program that calculates the total damage caused after the attack over the ship.

Input
The input data should be read from the console.
There will be exactly 11 lines holding the integer numbers SX1, SY1, SX2, SY2, H, CX1, CY1, CX2, CY2, CX3, and CY3. The ship S is given by any two of its opposite corners and is non-empty (has positive width and height). The line H is given by its vertical offset. The points C1, C2 and C3 are given as couples of coordinates and cannot overap each other.
The input data will always be valid and in the format described. There is no need to check it explicitly.

Output
The output data should be printed on the console.
The output should consist of a single line holding the total damage given as percentage.

Constraints
• The numbers SX1, SY1, SX2, SY2, H, CX1, CY1, CX2, CY2, CX3, and CY3 are all integers between -100 000 and 100 000, inclusive.
• Allowed work time for your program: 0.1 seconds.
• Allowed memory: 16 MB.

Examples
Practical exam_CSharp_Variant 1_b


РЕШЕНИЯ

Търсене