BC之jrMz and angles
jrMz and angles
jrMz has two types of angles, one type of angle is an interior angle of nn-sided
regular polygon, and the other type of angle is an interior angle of mm-sided
regular polygon. jrMz wants to use them to make up an angle of 360 degrees, which means, jrMz needs to choose some or none of the angles which belong to the first type and some or none of the angles which belong to the second type so that the sum value of
the angles chosen equals 360 degrees. But jrMz doesn’t know whether it is possible, can you help him?
The first line contains an integer T\left(1\leq
T\leq10\right)T(1≤T≤10)——The
number of the test cases. For each test case, the only line contains two integers n,m\left(1\leq
n,m\leq100\right)n,m(1≤n,m≤100) with
a white space separated.
For each test case, the only line contains a integer that is the answer.
3
4 8
3 10
5 8
Yes
Yes
No
In test case 1, jrMz can choose 1 angle which belongs to the first type and 2 angles which belong to the second type, because 90+135+135=360. In test case 2, jrMz can choose 6 angles which belong to the first type, because6\times60=360. In test case 3, jrMz can’t make up an angle of 360 degrees.
大水体,直接试一下就行了。。。
官方解:
不妨令n\leq mn≤m。
如果n>6n>6,由于所有角都大于120度且小于180度,也就是说,两个角一定不够,而三个角一定过多。因此一定无解;
当n\leq6n≤6时,如果n=3n=3或n=4n=4或n=6n=6,那么显然只需要正nn边形的角就可以了。如果n=5n=5,则已经有一个108度的角。若这种角:不取,则显然仅当m=6m=6时有解;取1个,则还差360-108=252360−108=252(度),但是没有一个正mm边形的内角的度数是252的约数;取2个,则还差360-108\times2=144360−108×2=144(度),这恰好是正10边形的内角,取3个,则还差360-108\times3=36360−108×3=36(度),也不可能满足;取大于3个也显然不可能。
因此得到结论:当nn和mm中至少有一个为3或4或6时,或者当nn和mm中一个等于5另一个等于10时,有解,否则无解,时间复杂度为
O\left(T\right)O(T)。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<ctime>
#define eps 1e-6
#define MAX 100005
#define INF 0x3f3f3f3f
#define LL long long
#define pii pair<string,int>
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d%d",&x,&y)
const int dir[][2] = { {-1, 0}, {0, -1}, { 1, 0 }, { 0, 1 } };
using namespace std;
int gcd (int a,int b){ int temp;
while(a/b!=0){
temp=a;
a=b;
b=a%b;
}
return b;
} int main()
{
int T;
int a ,b;
scanf("%d",&T);
while(T--)
{
rd2(a,b);
int mark=0;
int zi1=(a-2)*b,zi2=(b-2)*a;
int mu = a*b;
for(int i=0;i<=10;i++)
for(int j=0;j<=10;j++){
if((zi1*i+zi2*j)%(a*b)==0&&(zi1*i+zi2*j)/(a*b)==2)
mark=1,i=10,j=10;
//cout<<"ssssssssss"<<endl;
}
if(mark)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
BC之jrMz and angles的更多相关文章
- HDU 5660 jrMz and angles (暴力枚举)
jrMz and angles 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/E Description jrMz has tw ...
- jrMz and angles(水题)
jrMz and angles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- BestCoder Round #79 (div.2)-jrMz and angles,,暴力求解~
jrMz and angle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- 数据库设计范式2——BC范式和第四范式
我在很久之前的一篇文章中介绍了数据库模型设计中的基本三范式,今天,我来说一说更高级的BC范式和第四范式. 回顾 我用大白话来回顾一下什么是三范式: 第一范式:每个表应该有唯一标识每一行的主键. 第二范 ...
- BC之Claris and XOR
http://acm.hdu.edu.cn/showproblem.php?pid=5661 Claris and XOR Time Limit: 2000/1000 MS (Java/Others) ...
- bc:linux下命令行计算器
在linux下,存在一个命令行的计算器:bc.该程序一般随发行版发布. bc计算器能够执行一些基本的计算,包括+,-,×,\,%. 这些计算不经针对十进制,还可以使用二进制,八进制,十六进制,并且可以 ...
- bc#29 做题笔记
昨天的bc被坑惨了= = 本来能涨rating的大好机会又浪费了...大号已弃号 A:第一反应是高精度,结果模板找不到了= =,然后现学现卖拍了个java的BigInteger+快速幂,调了好半天不说 ...
- shell命令bc
简介 bc支持浮点数的精度运算(Bash不支持浮点数运算) 运行方式 一.CLI 二.PIPE 示例 一.浮点数运算 变量scale:设置小数点后面的位数 # 默认scale=0 echo &quo ...
- windbg-bp、 bm、 bu、 bl、 bc、 ba(断点、硬件断点)
bp bp 命令是在某个地址下断点, 可以 bp 0x7783FEB 也可以 bp MyApp!SomeFunction . 对于后者,WinDBG 会自动找到MyApp!SomeFunction 对 ...
随机推荐
- 类似baidu搜索 修正jquery的autocomplete在firefox下不支持中文输入法的bug
解决方法:
- google gtest window 平台应用
下载gtest:https://code.google.com/p/googletest/downloads/detail?name=gtest-1.7.0.zip 编译: 会出现的问题:error ...
- visual studio 2013 已停止运行 解决办法
情况是这样,WINDOWS 8.1,双显卡笔记本,打开VS.NET 没几秒就提示 已停止运行,然后就关闭程序了,找了无数资料都没有解决 -------------------------------- ...
- 用unity4.3发布WINDOWS STORE APP应用的方法
http://www.cnblogs.com/suxsho/ 原创,转载请声明 ============================================================ ...
- Spring使用ThreadLocal技术来处理这些问题
过去我习惯于从左到右的思考,因为这符合书写的习惯,对于“好”得前端工程师,我们首先可能会去思考什么是好,好的定义和范围,标准和要求?但现在我习惯于从右到左的思考,因为我觉得越是抽象越难以定义,从粒度更 ...
- cocos2d-x 帧循环不严谨造成场景切换卡顿
最近在用cocos2d-x做引导界面,2dx版本是2.2.3,场景切换加上了效果,所有资源都已经使用texturepacker打包预加载,但是在实际运行调试中,场景切换相当卡顿. 各种纠结后,无意中将 ...
- 另类vs2015+xamarin 的android界面乱码 解决
text.Text += "验证key 验证出错! 请在 AndroidManifest.xml 文件中检查 key 设置"; 代码就上面一行,单步走之前text.Text里面是汉 ...
- app后端设计(12)--图片的处理
app上线后,不断接受用户的反馈,于是,反馈非常差的情况下,都会有app的改版. 一旦app的改版,都会有比较大的UI改动,一改动UI,那么图片的尺寸也就必须要改变. 在app后端设计(1)—api( ...
- Python的标准输出
遇到什么就添加到这里来. 首先,是最基本的. print "Number is %d %f %s"%(intA,floatB,stringC) 如果对浮点数的精度有所要求的话,比如 ...
- oracle数据库从入门到精通之四
序列是oracle中较为重要的概念事务对于ddl是不起作用的查询,更新,数据表,约束这些个概念要掌握.在许多数据库之中都会存在一种数据类型--自动增长列,它能够创建流水号12c之前并没有提供这样一个自 ...