poj 1675 Happy Birthday!
来源:互联网 发布:vegas for mac 编辑:程序博客网 时间:2024/06/05 14:39
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.
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
22 1 1 -1 1 0 -110 0 9 1 8 -1 8
Sample Output
YesNo
给你三个豆 在原点为圆心半径为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;}
0 0
- POJ 1675 Happy Birthday
- poj 1675 Happy Birthday!
- poj 1675 Happy Birthday!
- POJ 1675 Happy Birthday! 笔记
- Happy birthday!
- HAPPY BIRTHDAY
- HAPPY BIRTHDAY!!
- Happy Birthday :)
- Happy Birthday
- happy birthday!
- happy birthday
- Happy birthday
- Happy Birthday~
- happy birthday
- happy birthday
- Happy Birthday to 亮
- Happy Birthday To Me!
- Happy Birthday --- TT
- makefile使用教程
- 初触Python,关于pyquery解析html(百度贴吧)
- 1081. Rational Sum (20)
- UVA_10739_StringToPalindrome
- 十大数据挖掘算法的R语言实现
- poj 1675 Happy Birthday!
- 如何自定义WPF项目的Main函数
- 新人报道
- Java中计算某一天所在周的星期一和星期天的日期函数
- 分享一种最简单的Android打渠道包的方法
- 《鸟哥的Linux私房菜-基础学习篇(第三版)》(三)
- Oracle - 数据库的实例、表空间、用户、表之间关系
- PHP 输出变量结构信息到日志
- Solr查询时设置字段的boost值,改变默认打分排序