poj 1675 Happy Birthday!
2015-08-17 14:43
357 查看
There are three berries on a round birthday cake. You are required to divide the cake into three identical parts such that each part contains exactly one berry. To make it easy, it is assumed that the radius of the berries is 0 and each part of the cake is
a sector with 120 degrees. Any line that divides the cake should not go through any berry.
![](http://poj.org/images/1675_1.jpg)
Input
The first line contains a single integer t (1 <= t <= 20) that indicates the number of test cases. Then follow the t cases. Each case contains exactly 7 integers r, x1, y1, x2, y2, x3 and y3. r is the radius of the cake, (xi, yi) is the coordinates of i-th
berry. The center of the cake is at (0, 0) and it's confirmed that all the berries will be on the cake.
Output
For each case, output 'Yes' if there is a valid solution, 'No' otherwise.
Sample Input
Sample Output
给你三个豆 在原点为圆心半径为r的圆内 可以可以切成三等分 让每个豆在不同的块里面
每等分120度 看他们之间是不是有超过120度的 有就YES
a sector with 120 degrees. Any line that divides the cake should not go through any berry.
![](http://poj.org/images/1675_1.jpg)
Input
The first line contains a single integer t (1 <= t <= 20) that indicates the number of test cases. Then follow the t cases. Each case contains exactly 7 integers r, x1, y1, x2, y2, x3 and y3. r is the radius of the cake, (xi, yi) is the coordinates of i-th
berry. The center of the cake is at (0, 0) and it's confirmed that all the berries will be on the cake.
Output
For each case, output 'Yes' if there is a valid solution, 'No' otherwise.
Sample Input
2 2 1 1 -1 1 0 -1 10 0 9 1 8 -1 8
Sample Output
Yes No
给你三个豆 在原点为圆心半径为r的圆内 可以可以切成三等分 让每个豆在不同的块里面
每等分120度 看他们之间是不是有超过120度的 有就YES
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std; const double pi=3.1415926; int main() { int t; cin>>t; while(t--) { double r; double x1,y1,x2,y2,x3,y3; cin>>r>>x1>>y1>>x2>>y2>>x3>>y3; double angl1; double angl2; double angl3; if((x1==0&&y1==0)||(x2==0&&y2==0)||(x3==0&&y3==0)) { cout<<"No"<<endl; } else { angl1=acos(((x1*x1+y1*y1)+(x2*x2+y2*y2)-((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)))/(2*sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2))); angl2=acos(((x1*x1+y1*y1)+(x3*x3+y3*y3)-((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)))/(2*sqrt(x1*x1+y1*y1)*sqrt(x3*x3+y3*y3))); angl3=acos(((x2*x2+y2*y2)+(x3*x3+y3*y3)-((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)))/(2*sqrt(x2*x2+y2*y2)*sqrt(x3*x3+y3*y3))); angl1=angl1*180/pi; angl2=angl2*180/pi; angl3=angl3*180/pi; double maxn; maxn=max(angl1,angl2); maxn=max(maxn,angl3); if(maxn<120) { cout<<"No"<<endl; } else { cout<<"Yes"<<endl; } } } return 0; }
相关文章推荐
- QQ微信号数据库 微信号采集 可区分性别地区1-100万个
- swift学习笔记之数据类型
- Unity后台是如何执行脚本的
- IT时代里,有那些方法进行APP营销
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- 【动态规划】POJ2385-Apple Catching
- ios下mach_absolute_time获取精准时间
- iOS- 利用AFNetworking(AFN) - 实现图片上传
- android开发 自定义图文混排控件
- call和apply的深入理解
- Android 动画详解
- android sdk 离线安装
- 获取Android手机SD卡容量大小
- Android笔记:去除标题栏
- iOS开发--CGBitmapContextCreate函数
- Android清除本地数据缓存代码
- AndroidStudio开发工具快捷键整理分享
- php判断网页是否是手机访问和微信访问
- Android事件分发机制
- iOS 绘制1像素线条总结