Pro.ID22804 TitleBalance Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22804 AC1 Submit1 Ratio100.00% 时间&空间限制描述A sailboat has many forces acting onit. This allows it to sail in many different directions, even if the wind isnot blowing in the desired direction. In order for the boat to be easilycontrolled, however, certain forces must be balanced. Suppose the wind is blowing from thenorth and the boat is facing west. Above the water, the blowing wind hits thesails, and because of the way that they are angled, pushes the boat to thesouthwest. The keel extends deep below the water. The water resistance on thekeel creates a counterforce pushing the boat northward. Ideally, the northwardforce on the keel will counteract the southward component of the force on thesails, so that the boat will move to the west. A problem can arise if the centre ofthe sails (called the Centre of Effort, or CE) is not directly above the centreof the keel (called the Centre of Lateral Resistance, or CLR). In general, theboat can pivot about the centre of the keel. If the sails are too far forwardof the keel, the wind will push the bow (the front) of the boat southwards, andthe boat will turn towards the south. If the sails are too far aft of (behind)the keel, the wind will push the stern (the back) southwards, and the boat willturn towards the north. Ideally, the sails and keel are balanced so that theboat sails in a straight line. In this problem, you will examine a side view of theboat to determine whether the CE is above the CLR. The CE is defined as thecentroid of the part of the boat above the waterline. The CLR is defined as thecentroid of the part of the boat below the waterline. The centroid of a polygonis the unique point such that any line passing through it divides the polygoninto two halves of equal area. 输入The first line of input will contain asingle integer n specifying thenumber of points along the outline of the side view of the boat. The followingn lines will each contain two integers: the x and y coordinate of apoint along the outline. The points will be given in order along the outline.The x axis (i.e. the line y = 0)represents the waterline. Assume that the boat faces in the direction ofincreasing x coordinates. 输出Description A sailboat has many forces acting onit. This allows it to sail in many different directions, even if the wind isnot blowing in the desired direction. In order for the boat to be easilycontrolled, however, certain forces must be balanced. Suppose the wind is blowing from thenorth and the boat is facing west. Above the water, the blowing wind hits thesails, and because of the way that they are angled, pushes the boat to thesouthwest. The keel extends deep below the water. The water resistance on thekeel creates a counterforce pushing the boat northward. Ideally, the northwardforce on the keel will counteract the southward component of the force on thesails, so that the boat will move to the west. A problem can arise if the centre ofthe sails (called the Centre of Effort, or CE) is not directly above the centreof the keel (called the Centre of Lateral Resistance, or CLR). In general, theboat can pivot about the centre of the keel. If the sails are too far forwardof the keel, the wind will push the bow (the front) of the boat southwards, andthe boat will turn towards the south. If the sails are too far aft of (behind)the keel, the wind will push the stern (the back) southwards, and the boat willturn towards the north. Ideally, the sails and keel are balanced so that theboat sails in a straight line. In this problem, you will examine a side view of theboat to determine whether the CE is above the CLR. The CE is defined as thecentroid of the part of the boat above the waterline. The CLR is defined as thecentroid of the part of the boat below the waterline. The centroid of a polygonis the unique point such that any line passing through it divides the polygoninto two halves of equal area. Input The first line of input will contain asingle integer n specifying thenumber of points along the outline of the side view of the boat. The followingn lines will each contain two integers: the x and y coordinate of apoint along the outline. The points will be given in order along the outline.The x axis (i.e. the line y = 0)represents the waterline. Assume that the boat faces in the direction ofincreasing x coordinates. Output If the CE is forward of the CLR, print the line: CE is forward of CLR by N units. If the CE is after of (behind) the CLR, print the line: CE is aft of CLR by N units. In both cases, replace the N with the difference in the x coordinates of the CE and CLR to two decimal places. If the x coordinates of the CE and CLR are equal, print the line: Balanced. Sample Input 7 Sample Output CE is aft of CLR by 0.50 units. Source 样例输入7 样例输出CE is aft of CLR by 0.50 units. 作者 |