Educational Codeforces Round 57 (Rated for Div. 2) C 正多边形 + 枚举
https://codeforces.com/contest/1096/problem/C
题意
问是否存在一正多边形内三点构成的角度数为ang,若存在输出最小边数
题解
- 三点构成的角是个圆周角,假设n为多边形边数,则能构成的角范围是\(\frac{180}{n} \leq ang \leq \frac{n-2}{n}*180\),每次变化\(\frac{180}{n}\)
- 首先明确正多边形一定存在,并且最大边数不会超过360,若边数等于360,则可以组成的角的范围是\(0.5\leq ang \leq 179\),每次变化\(0.5\),所以所有的ang都能组成
- 所以枚举边数,然后再枚举使用的内角数即可
代码
#include<bits/stdc++.h>
using namespace std;
int t,ang,i,st,tp,ok;
int main(){
cin>>t;
while(t--){
ok=0;
cin>>ang;
for(int i=1;i<=180;i++){
for(int j=1;j*180.0/i<=ang&&j<=i-2;j++){
if(j*180.0/i==ang){
cout<<i<<endl;
ok=1;
break;
}
}
if(ok)break;
}
if(!ok)cout<<360<<endl;
}
}
Educational Codeforces Round 57 (Rated for Div. 2) C 正多边形 + 枚举的更多相关文章
- Educational Codeforces Round 57 (Rated for Div. 2) ABCDEF题解
题目总链接:https://codeforces.com/contest/1096 A. Find Divisible 题意: 给出l,r,在[l,r]里面找两个数x,y,使得y%x==0,保证有解. ...
- Educational Codeforces Round 57 (Rated for Div. 2) D dp
https://codeforces.com/contest/1096/problem/D 题意 给一个串s,删掉一个字符的代价为a[i],问使得s的子串不含"hard"的最小代价 ...
- Educational Codeforces Round 57 (Rated for Div. 2)
我好菜啊. A - Find Divisible 好像没什么可说的. #include<cstdio> #include<cstring> #include<algori ...
- Educational Codeforces Round 57 (Rated for Div. 2)D(动态规划)
#include<bits/stdc++.h>using namespace std;char s[100007];long long a[100007];long long dp[100 ...
- Educational Codeforces Round 57 (Rated for Div. 2) 前三个题补题
感慨 最终就做出来一个题,第二题差一点公式想错了,又是一波掉分,不过我相信我一定能爬上去的 A Find Divisible(思维) 上来就T了,后来直接想到了题解的O(1)解法,直接输出左边界和左边 ...
- Educational Codeforces Round 94 (Rated for Div. 2) D. Zigzags (枚举,前缀和)
题意:有一长度为\(n(4\le n\le 3000)\)的数组,选择四个位置\((i,j,k,l)\ (1\le i<j<k\le n)\),使得\(a_i=a_k\)并且\(a_j=a ...
- Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题
Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] 总共两次询 ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
随机推荐
- Unreal Engine 4 系列教程 Part 8:粒子系统教程
.katex { display: block; text-align: center; white-space: nowrap; } .katex-display > .katex > ...
- ThinkPHP查询数据的时候toArray()报错解决办法
当查找不到数据时toArray()会报错,如图 解决办法:先查找数据,然后加个判断,如果有数据再转化为数组,如果没有数据就给个空值,不想代码继续往下执行就return false;
- Window权限维持(三):服务
如果未正确配置Windows环境中的服务或这些服务可以用作持久性方法,则这些服务可能导致权限提升.创建一个新的服务需要管理员级别的特权,它已经不是隐蔽的持久性技术.然而,在红队的行动中,针对那些在威胁 ...
- 【UOJ#62】【UR #5】怎样跑得更快(莫比乌斯反演)
[UOJ#62][UR #5]怎样跑得更快(莫比乌斯反演) 题面 UOJ 题解 众所周知,\(lcm(i,j)=\frac{ij}{gcd(i,j)}\),于是原式就变成了: \[\sum_{j=1} ...
- A Pattern Language for Parallel Programming
The pattern language is organized into four design spaces. Generally one starts at the top in the F ...
- Windows 10应答文件
将其保存为autounattend.xml文件,然后放入到ISO镜像根目录即可 <?xml version="1.0" encoding="utf-8"? ...
- 最全面的PS快捷键使用指南(图文演示)
每次做图的时候都会记错快捷键,很苦恼有木有!!!只能各处搜寻PS快捷键汇总起来,老板再也不会说我作图慢了....... 1.Ctrl+T:自由变形 该快捷键,主要对图层进行旋转.缩放等变形调整,同时可 ...
- 第一章 权限管理DEMO简介
源代码GitHub:https://github.com/ZhaoRd/Zrd_0001_AuthorityManagement 1.系列介绍 工作已有五年之久,一直有想通过博客写点自己知道的,在博客 ...
- annyconnect掉线之后重新链接
sudo service vpnagentd restart /opt/cisco/anyconnect/bin/vpnui 重启服务+重新登录 deepin的优点之一是它的程序不会安装到各个角落里, ...
- ztree选父不选子选子不选父
var setting = { data: { simpleData: { enable: true } } ,check: { enable: true , chkStyle: 'checkbox' ...