B. Mister B and Angle in Polygon
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 v1, v2, v3 such
that the angle (where v2 is
the vertex of the angle, and v1 and v3 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.

Input

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.

Output

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

Examples
input
3 15
output
1 2 3
input
4 67
output
2 1 3
input
4 68
output
4 1 2
Note

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".

————————————————————————————————

题目的意思是给出一个正n凸多边形,让你选择3个顶点所成角度尽可能接近给出的角度k

思路:我们选一个顶点把他和与他不相邻的点连线一定会把一个角(n-2)等分,枚举选择的角度与k比就好了

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define LL long long
const int inf=0x3f3f3f3f; int main()
{
int n,x;
scanf("%d%d",&n,&x);
double p=180.0/n;
double ans=inf;
int cnt=-1;
for(int i=1; i<=n-2; i++)
{
if(fabs(ans-x)-fabs(p*i-x)>1e-9)
ans=p*i,cnt=i;
}
printf("%d %d %d\n",n-cnt,1,n);
return 0;
}

codeforces820B Mister B and Angle in Polygon 2017-06-28 09:42 123人阅读 评论(0) 收藏的更多相关文章

  1. Codeforces820A Mister B and Book Reading 2017-06-28 09:38 67人阅读 评论(0) 收藏

    A. Mister B and Book Reading time limit per test 2 seconds memory limit per test 256 megabytes input ...

  2. Codeforces 820B - Mister B and Angle in Polygon

    820B - Mister B and Angle in Polygon 思路: 由于正多边形以某个顶点分成的三角形后以这个点为顶点的角都相等,所以可以确定两个点为相邻点,只要再找一个点就够了. 证明 ...

  3. Codeforces Round #421 (Div. 2)B. Mister B and Angle in Polygon(模拟+精度控制)

    传送门 题意 给出正n多边形和一个数a,寻找与a最接近的角,输出角编号 分析 找出多边形上所有角,一一比对即可 trick 1.判断的时候注意精度,i.e.x-eps>0 2.double与do ...

  4. 【Codeforces Round #421 (Div. 2) B】Mister B and Angle in Polygon

    [题目链接]:http://codeforces.com/contest/820/problem/B [题意] 给你一个正n边形; 然后让你在这正n边行中选3个点,组成一个角; 找出角的大小和所给的角 ...

  5. 【资料下载区】【GMT43相关代码、资料下载地址】更新日期2017/06/28

    [GMT43相关文档][更新中...] GMT43原理图(PDF)下载GMT43说明书(PDF)下载GMT43机械结构尺寸(PDF)下载 [GMT43相关例程代码][ARM][更新中...] 基于HA ...

  6. 团队作业4——第一次项目冲刺(Alpha版本)2017.4.28

    2017.04.28 天气晴朗 东风3级. 时间:上午 9:35 ---10:10分 地点:陆大二楼 会议内容:实验室报修系统项目冲刺Alpha版的的最后一天,大家对现在项目的进程进行了讨论,阐述了各 ...

  7. HDU 6055 - Regular polygon | 2017 Multi-University Training Contest 2

    /* HDU 6055 - Regular polygon [ 分析,枚举 ] 题意: 给出 x,y 都在 [-100, +100] 范围内的 N 个整点,问组成的正多边形的数目是多少 N <= ...

  8. HDU 6055 Regular polygon —— 2017 Multi-University Training 2

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  9. hdu 6055 : Regular polygon (2017 多校第二场 1011) 【计算几何】

    题目链接 有个结论: 平面坐标系上,坐标为整数的情况下,n个点组成正n边形时,只可能组成正方形. 然后根据这个结论来做. 我是先把所有点按照 x为第一关键字,y为第二关键字 排序,然后枚举向量 (p[ ...

随机推荐

  1. vs 调试 IE显示“无法显示该网页

    在用VS2010调试网站的时候,突然页面不能正常显示了,IE显示“无法显示该网页”.症状一: IE地址栏里面显示的端口号和桌面任务栏右下角“ASP.NET Development Server”的端口 ...

  2. 网页 PHP 动态师范

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. windows上安装RabbitMQ

    windows下 安装 rabbitMQ 及操作常用命令 rabbitMQ是一个在AMQP协议标准基础上完整的,可服用的企业消息系统.它遵循Mozilla Public License开源协议,采用 ...

  4. dataTables的学习笔记 -- 未开启服务器数据模式

    官方网站:http://www.datatables.net/ (1)未开启服务器数据模式(即"bServerSide" : false),数据会从后台直接全部获取,然后在前台全部 ...

  5. Luogu 1764 翻转游戏 - 枚举 + 搜索

    题目描述 kkke在一个n*n的棋盘上进行一个翻转游戏.棋盘的每个格子上都放有一个棋子,每个棋子有2个面,一面是黑色的,另一面是白色的.初始的时候,棋盘上的棋子有的黑色向上,有的白色向上.现在kkke ...

  6. POJ 3169.Layout 最短路

    Layout Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11612   Accepted: 5550 Descripti ...

  7. boost的accumulator rolling_mean的使用

    Boost.Accumulators is both a library for incremental statistical computation as well as an extensibl ...

  8. Java SE学习【三】——JDBC

    最近学到了数据库与java的jdbc方面,还有个DAO模式,写一下自己的理解,后期有什么不对的再改. 一.数据库三范式的理解 记得以前上课时,也上了一学期的“数据库系统原理”,给我们上课的老师算是渣渣 ...

  9. 【转载】为什么任何随便输入的账号使用SYSDBA权限都能登陆oracle

    其实简单点就是检查一下你的机器有没有一个ora_dba用户组,而且你登陆os的用户是否在这个组里,有的话问题的原因就找到了,下面是转的高手的介绍 本文环境配置:Oracle10gR2,Windows ...

  10. css进阶篇

    一.css的属性值 1)字体属性 font-size: 5px; /* 字体大小 */ font-size: 20px/50%/larger /* 字体的大小 */ font-family:'Luci ...