编程介的小学生 2017-04-10 15:24 采纳率: 20.5%
浏览 890
已采纳

Form a Square

Have you ever put up a tent on top of a mountain? The difficulty lies in finding the appropriate positions to fix the nails on the ground, which is a mostly exposed rock where we can hardly press the nails.
In our problem we have a square tent, which means we need to fix the four vertices on the ground. For some reason the size of the tent is not very important, but we need to accurately fix the vertices to form a square. Now we have picked four spots that are suitable to press the nails and your job is to decide whether the spots form a square.

Input Description

Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 50) which is the number of test cases. T test cases follow, each preceded by a single blank line.

Each test case contains 4 lines for the coordinates of the four distinct vertices that are picked. Each line contains the x and y coordinates separated by a single space (0 < x, y < 1,000). But please notice that the coordinates are not necessarily given in either clockwise or counterclockwise order for a square.

Output Description

Results should be directed to standard output. Start each case with "Case #:" on a single line, where # is the case number starting from 1. Two consecutive cases should be separated by a single blank line. No blank line should be produced after the last test case.

The output should be either "Yes" or "No", indicating whether or not the four given positions can form a square.

Sample Input

3

1 1
1 2
2 1
2 2

1 1
2 2
3 3
4 4

1 2
2 1
2 3
3 2

Sample Output

Case 1:
Yes

Case 2:
No

Case 3:
Yes

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-04-27 06:20
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试