Timus #1207

题目说明:二维坐标上有一堆点,选两点作为一条直线,把所有点分成两堆

题目解析:极角排序。找到x轴最小的点,其他所有点求atan2,进行排序,取最小点和排列后中间点的index索引输出。

Problem analysis English version:

  • Find minimum x in points.
  • Store atan2 which is theta between minimum x and origin and the index of each point.
  • Use bubble sort to sort atan2 result.
  • Output the index of minimum x and the number in the middle of the series.

代码说明:个人写了冒泡排序,没用c++ sort 和结构体,相对来说代码可读性较差,可以对此进行改进

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

浙ICP备2021019730-1    浙公网安备 33010902002953号
Copyright © 2024 PanCake