编程介的小学生 2016-12-30 12:29 采纳率: 20.5%
浏览 814
已采纳

Blast the Enemy!

Description

A new computer game has just arrived and as an active and always-in-the-scene player, you should finish it before the next university term starts. At each stage of this game, you have to shoot an enemy robot on its weakness point. The weakness point of a robot is always the “center of mass” of its 2D shape in the screen. Fortunately, all robot shapes are simple polygons with uniform density and you can write programs to calculate exactly the center of mass for each polygon.

Let's have a more formal definition for center of mass (COM). The center of mass for a square, (also circle, and other symmetric shapes) is its center point. And, if a simple shape C is partitioned into two simple shapes A and B with areas SA and SB, then COM(C) (as a vector) can be calculated by

As a more formal definition, for a simple shape A with area SA:

Input

The input contains a number of robot definitions. Each robot definition starts with a line containing n, the number of vertices in robot’s polygon (n <= 100). The polygon vertices are specified in the next n lines (in either clockwise or counter-clock-wise order). Each of these lines contains two space-separated integers showing the coordinates of the corresponding vertex. The absolute value of the coordinates does not exceed 100. The case of n=0 shows the end of input and should not be processed.
Output

The ith line of the output should be of the form “Stage #i: x y” (omit the quotes), where (x,y) is the center of massfor the ith robot in the input. The coordinates must be rounded to exactly 6 digits after the decimal point.
Sample Input

4
0 0
0 1
1 1
1 0
3
0 1
1 0
2 2
8
1 1
2 1
2 7
3 7
3 0
0 0
0 7
1 7
0
Sample Output

Stage #1: 0.500000 0.500000
Stage #2: 1.000000 1.000000
Stage #3: 1.500000 3.300000

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-12-30 15:21
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题