CF820B.Mister B and Angle in Polygon

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).

That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices _v_1, _v_2, _v_3 such that the angle (where _v_2 is the vertex of the angle, and _v_1 and _v_3 lie on its sides) is as close as possible to a. In other words, the value should be minimum possible.

If there are many optimal solutions, Mister B should be satisfied with any of them.

在一个宁静的日子里,B先生突然决定在他的田地上画一个角度 aa。外星人早已造访过他的田地,并在上面留下了各种不同的几何图形。其中有一个图形是正 nn 边形(即具有 nn 条边的正凸多边形)。

因此,B先生决定利用这个多边形。现在,B先生必须找出三个互不相同的顶点 v1v_1、v2v_2、v3v_3,使得角 ∠v1v2v3\angle v_1 v_2 v_3(其中 v2v_2 是该角的顶点,v1v_1 和 v3v_3 分别位于其两边上)尽可能接近 aa。换言之,值 ∣∠v1v2v3−a∣\left| \angle v_1 v_2 v_3 - a \right| 应尽可能小。

若存在多个最优解,B先生接受其中任意一个即可。

输入格式

First and only line contains two space-separated integers n and a (3 ≤ n ≤ 105, 1 ≤ a ≤ 180) — the number of vertices in the polygon and the needed angle, in degrees.

第一行且唯一一行包含两个以空格分隔的整数 nn 和 aa(3 ≤ n ≤ 1053 \leq n \leq 10^5,1 ≤ a ≤ 1801 \leq a \leq 180)——分别为多边形的顶点数和所需的角度(单位:度)。

输出格式

Print three space-separated integers: the vertices _v_1, _v_2, _v_3, which form . If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.

输出三个用空格分隔的整数:构成 的顶点 v1v_1、v2v_2、v3v_3。若存在多个最优解,输出其中任意一个即可。顶点按顺时针方向编号为 11 到 nn。

输入输出样例

  • 输入#1

    3 15

    输出#1

    1 2 3
  • 输入#2

    4 67

    输出#2

    2 1 3
  • 输入#3

    4 68

    输出#3

    4 1 2

说明/提示

In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.

Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".

In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".

在第一个样例测试中,正三角形的顶点只能构成 60∘60^\circ 的角,因此所有可能的角度都是正确的。

正方形的顶点只能构成 45∘45^\circ 或 90∘90^\circ 的角。因此,在第二个样例测试中选择了 45∘45^\circ 的角,因为 ∣45 − 67∣ < ∣90 − 67∣|45 - 67| < |90 - 67|。其他正确答案为:“3 1 2”、“3 2 4”、“4 2 3”、“4 3 1”、“1 3 4”、“1 4 2”、“2 4 1”、“4 1 3”、“3 1 4”、“3 4 2”、“2 4 3”、“2 3 1”、“1 3 2”、“1 2 4”、“4 2 1”。

在第三个样例测试中,相反地,选择了 90∘90^\circ 的角,因为 ∣90 − 68∣ < ∣45 − 68∣|90 - 68| < |45 - 68|。其他正确答案为:“2 1 4”、“3 2 1”、“1 2 3”、“4 3 2”、“2 3 4”、“1 4 3”、“3 4 1”。

输入解题思路,AI测评打分。不知道怎么写?

首页