题目链接:http://codeforces.com/contest/820/problem/B

题意:给定一个正n边形,然后让你选择3个不同的顶点,使得这3个顶点形成的角度尽可能的接近a。

思路:首先模拟一下画个图发现因为是正n边形所以可以固定2个相邻的顶点然后找第3个顶点既可,这里先固定顶点1和2并且以顶点2为中点,然后枚举其他n-2个顶点计算夹角度数取最优即可。  我们知道正n边形的内角为(n-2)/n*180°,由于固定了2个相邻的顶点所以一个内角可以被划分成(n-2)份,所以每份的度数det为((n-2)/n*180)/(n-2)°。

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<time.h>
#include<stack>
#include<cmath>
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
const int MAXN = + ;
int main(){
//#ifdef kirito
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//#endif
// int start = clock();
int n, a;
while (~scanf("%d%d", &n,&a)){
int v3=n;
double cur = ,det=(1.0*(n-)/n*180.0)/(1.0*n-);
for (int i = n; i >= ; i--){
if (fabs(cur - a) > fabs(det*(n - i + ) - a)){
cur = det*(n - i + );
v3 = i;
}
}
printf("%d %d %d\n",, , v3);
}
//#ifdef LOCAL_TIME
// cout << "[Finished in " << clock() - start << " ms]" << endl;
//#endif
return ;
}

Codeforces Round #421 (Div. 2) - B的更多相关文章

  1. Codeforces Round #421 (Div. 2) D. Mister B and PR Shifts

    Codeforces Round #421 (Div. 2) D. Mister B and PR Shifts 题意:给一个长度为\(n\)的排列,每次可以向右循环移位一次,计算\(\sum_{i= ...

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

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

  3. 【Codeforces Round #421 (Div. 2) A】Mister B and Book Reading

    [题目链接]:http://codeforces.com/contest/820/problem/A [题意] 每天看书能看v页; 且这个v每天能增加a; 但是v有上限v1; 然后每天还必须往回看t页 ...

  4. Codeforces Round #421 (Div. 2) - A

    题目链接:http://codeforces.com/contest/820/problem/A 题意:一个人在看一本书,书一共C页,这个人每天看v0页,但是他又开始加速看这本书,每天都比前一天多看a ...

  5. Codeforces Round #421 (Div. 2)

    A: 题意:给你一本书共c页,第一天看v0页,第二天看v0+a,第二天看v0+2a以此类推,每天最多看v1页,但是后一天要重复看前一天的后l页. 代码: #include<stdio.h> ...

  6. Codeforces Round #421 (Div. 2)D - Mister B and PR Shifts(模拟)

    传送门 题意 给出n个数,计算在进行n-1次右移中\(min\sum_{i=1}^nabs(p_i-i)\) 分析 我们设置cnt[p[i]-i]为一个数p[i]与它标准位置(如1的标准位置为1)的左 ...

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

  8. Codeforces Round #421 (Div. 1) (BC)

    1. 819B Mister B and PR Shifts 大意: 给定排列$p$, 定义排列$p$的特征值为$\sum |p_i-i|$, 可以循环右移任意位, 求最小特征值和对应移动次数. 右移 ...

  9. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

随机推荐

  1. php XDebug配置和使用

    已本机php 5.5nts为例,php.ini配置如下: [XDebug] xdebug.profiler_append = 0 xdebug.profiler_enable = 1 xdebug.p ...

  2. Android使用命令行操作数据库

    所有的应用程序本地文件都存放在/data/data/目录下 C:\Users\nicole>adb shell * daemon not running. starting it now on ...

  3. linux 多进程并发服务__关于子进程回收的方法

    以TCPServ 服务程序来说: 1)父进程:负责系统初始化,以及监听(listen),接受连接请求(accept);其中accept 默认阻塞调用. 2)每接受一个连接请求,动态新建(fork)一个 ...

  4. SpringMVC常用方法总结

    *) @RequestMapping(value="/xxx/{id}",method={RequestMethod.GET}) method 不写的话,默认GET.POST都支持 ...

  5. Mybatis, 实现一对多

    我这里是拿商品做为例子 不多说直接上代码 Mapper.xml <?xml version="1.0" encoding="UTF-8"?> < ...

  6. edusoho 支持同一账号多人同时登录

    文件: ./src/Topxia/WebBundle/Listener/UserLoginTokenListener.php 函数: public function onGetUserLoginLis ...

  7. python 浮点运算

    print(format(float(a)/float(b),'.2f'))

  8. Rtmp AAC基本格式(转)

    第一个audio data包:AAC sequence header 第二个audio data包:AAC raw AF表示的含义: 1)第一个字节af,a就是10代表的意思是AAC, Format ...

  9. All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

    ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control character ...

  10. vmware14克隆后UUID相同的解决方法

    查看网卡 UUID值 [root@localhost network-scripts]# nmcli connection showNAME UUID TYPE DEVICE ens33 cf228d ...