本文主要是介绍【百炼oj】1675:Happy Birthday!,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
描述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.
2 2 1 1 -1 1 0 -1 10 0 9 1 8 -1 8样例输出
Yes No
#include<stdio.h>
#include<math.h>
int main(){int check(double a,double b,double c);int n,i,j;int test[7];double a,b,c,pi=atan(1)*4;scanf("%d",&n);for(i=0;i<n;i++){for(j=0;j<7;j++)scanf("%d",&test[j]);if((test[1]==0&&test[2]==0)||(test[3]==0&&test[4]==0)||(test[5]==0&&test[6]==0))printf("No\n");else{a=atan2(test[1],test[2]);b=atan2(test[3],test[4]);c=atan2(test[5],test[6]);if(check(a,b,c))printf("No\n");else printf("Yes\n");}}}int check(double a,double b,double c){//判断是否可分double temp;double pi=atan(1)*4;double k[3];k[0]=a;k[1]=b;k[2]=c;int i,j;for(i=0;i<3;i++){for(j=i;j<3;j++){if(k[i]>k[j]){temp=k[i];k[i]=k[j];k[j]=temp;}}}if(a==b||a==c||b==c)return 1;else{if((k[2]-k[0])<=2*pi/3)return 1;if((2*pi-k[1]+k[0])<=2*pi/3)return 1;if((2*pi-k[2]+k[1])<=2*pi/3)return 1;return 0;}
}
这篇关于【百炼oj】1675:Happy Birthday!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!