C. Polygon for the Angle
You are given an angle angang.
The Jury asks You to find such regular nn-gon (regular polygon with nn vertices) that it has three vertices aa, bb and cc (they can be non-consecutive) with ∠abc=ang∠abc=ang or report that there is no such nn-gon.
If there are several answers, print the minimal one. It is guarantied that if answer exists then it doesn't exceed 998244353998244353.
Input
The first line contains single integer TT (1≤T≤1801≤T≤180) — the number of queries.
Each of the next TT lines contains one integer angang (1≤ang<1801≤ang<180) — the angle measured in degrees.
Output
For each query print single integer nn (3≤n≤9982443533≤n≤998244353) — minimal possible number of vertices in the regular nn-gon or −1−1 if there is no such nn.
思路:模拟:最少三个点才能有角度,所以从3开始模拟
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define mod 998244353
using namespace std;
double n;
int main(){int t;cin>>t;while(t--){cin>>n;int i,f=0;for(i=3;i<400;i++){double du=360.0/i;for(int j=1;j<i-1;j++){//i-1表示若分为i份,最多i-2个组成角度int a=(int)j*du/2;if(a==n){f=1;break;}}if(f)break;}cout<<i<<endl;}return 0;
}
使用gcd,求出和180的最大公约数,
#include<bits/stdc++.h>
using namespace std;
int T,n,ans;
int main(){cin>>T;while(T--){cin>>n;int zz=__gcd(n,180);zz=180/zz;while(180*(zz-2)/zz<n) zz*=2;cout<<zz<<endl;}return 0;
}
C. Polygon for the Angle相关推荐
- c语言polygon函数,C. Polygon for the Angle(几何)
题目大意:T是测试样例,然后每一次输入一个角度,然后问你在一个n边形里面,能不能构成这个角度,如果能,输出边数,如果没有就输出-1. 具体思路:利用一个性质,四边形内的每个点都能被这个四边形内的最小的 ...
- Polygon for the Angle
https://codeforces.com/contest/1096/problem/C 题解:暴力就好 /* *@Author: STZG *@Language: C++ */ #include ...
- python有趣的案例_Python有趣的小案例
# 所需依赖:python3 pycharm # print 打印 print('hello world!') # 注释符号 # 井号后面灰色的内容是注释,相当于笔记,会被机器忽略 # 变量和值 # ...
- 我的一个windows phone program
//花费了一下午的时间我终于完成了这个小程序 对然代码很简单但毕竟我才刚刚接触这些 <phone:PhoneApplicationPage x:Class="Myclock.MainP ...
- Educational Codeforces Round 57 (Rated for Div. 2)
我好菜啊. A - Find Divisible 好像没什么可说的. #include<cstdio> #include<cstring> #include<algori ...
- python画超长图-利用Python画图,千变万化,各种画图技巧!
如图所示,利用Python的turtle画了一个美国队长盾牌的标志: # 所需依赖:python3 sublime Python代码: # print 打印 print('hello world!') ...
- 海龟画图----python画美队盾牌
之前上选修课老师首先讲的就是海龟画图,后来还是稍微研究一下了的,海龟画图其实还是蛮有趣的,随便改一些数据可以画出意料之外的惊喜. 开发环境 :win10 + pycharm 需要的包就是turtle, ...
- Python有趣的小案例-美国队长盾牌
# 导入 turtle 模块 # 模块是 python 自带的工具箱,这里将工具箱导入就能使用了 # turtle 模块是 python 用来画图的工具箱 import turtle# 将 turtl ...
- cube函数matlab_Matlab geom3d函数注释
Matlab geom3d函数解析 geom3d函数库 geom3d库的目的是处理和可视化三维几何原语,如点.线.平面.多面体等.它提供了操作三维几何原语的底层功能,使得开发更复杂的几何算法变得更加容 ...
最新文章
- SQL Server数据库查询速度慢的原因和解决方法
- 玩玩自动化测试之selenium篇
- Python基础——PyCharm版本——第七章、面向对象编程
- 工作环境总结(1)开发环境搭建
- 把旧系统迁移到.Net Core 2.0 日记(1) - Startup.cs 解析
- 【c++ primer读书笔记】【第2章】变量和基本类型
- 多窗口售票:单件模式多线程实现
- 【ROS学习笔记】(三)发布者Publisher的实现
- cmd bat 相对命令
- css 适配mac 字体,CSS:仅在mac上使用字体
- laya fgui 超简单的UI框架
- 小波包分解、重构、去噪与matlab函数使用
- python电脑版微信-微信PC版的API接口 | 可通过Python调用微信功能
- 使用 f2py 包装 Fortran MPI 程序
- 【人工智能项目】sg2im文字转图像
- 前端开发之走进Vue.js(入门者看过来)
- 环保数采仪下的污染物PM2.5在线监测方案
- 硕士毕业去一线城市的企业好,还是去三线城市做公务员好?
- 服务器安装与维护,服务器安装与维护 PPT课件
- 牛逼啦!20行Python代码让程序自动玩“合成大西瓜”!
热门文章
- 三星平板 N8000刷机升级安卓版本到7.1过程记录
- 网络安全专家,这5本入门秘籍人手一套
- 产品经理用什么工具干活?
- 7-8 金银铜牌 (15 分)
- html mp3默认播放器,酷狗如何设置为默认的歌曲播放器
- MVC模式计算两个正数的代数平均值与几何平均值
- eplan可运行于linux系统吗,Eplanp82.6安装对电脑操作系统的要求
- Spark报错:Error:scalac: Scala compiler JARs not found (module ‘Spark_two‘): C:\Users\沫小新\.m2\repo
- 技术栈-拓展延伸-redis学习总结
- CefSharp 中断点 已达到中断点