【百炼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.
输入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.输出For each case, output 'Yes' if there is a valid solution, 'No' otherwise.样例输入
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;
    }
}

Happy Birthday

09-06

Problem Descriptionn一声欢笑一段岁月n一天又添一年年纪n一场相逢一群朋友n一生永伴一窝萝卜n —— Wiskey祝nn兔子生日罗,大家为她准备了个篝火晚会来庆祝,晚会上大家手拉着手围着篝火玩报数游戏,每个人都被编了个号,因为今天兔子是主角,所以她站在中间,左右都是比她编号大的人,其他人也按着这个规则牵手,即编号小的站中间,左右手各拉着一个比自己编号大的人(不是手牵着手),或者不拉着任何一个人,不形成环。报数游戏规则如下,一个人要等左手边的人报完,再报出自己的编号,接着就是右手边的人报,如果谁傻在那,不知道该谁报的就得出来表演节目。玩了一会后,兔子就感觉没意思了,她换了个规则,先报出自己的编号,再左边的人报数,然后右边。每次都是从兔子开始,兔子是这群人里编号最小的。nWiskey向来对数字不敏感,虽然他运气很好的通过了第一种规则游戏的考验,但并不表示也能顺利通过第二种规则游戏。现在你的任务就是告诉Wiskey他在第二个序列中的位置。n nnInputn第一行两个整数N和M (N<50000),表示人数,M表示Wiskey的编号。n接下有N个整数,表示编号,每个人的编号都不同 。n nnOutputn输出Wiskey在第二种规则报数序列中的位置。n nnSample Inputn6 5n0 2 1 4 5 3nn6 5n4 2 5 1 3 6n nnSample Outputn6n4

Happy birthday

06-15

Problem DescriptionnToday is Gorwin’s birthday. So her mother want to realize her a wish. Gorwin says that she wants to eat many cakes. Thus, her mother takes her to a cake garden. nnThe garden is splited into n*m grids. In each grids, there is a cake. The weight of cake in the i-th row j-th column is wij kilos, Gorwin starts from the top-left(1,1) grid of the garden and walk to the bottom-right(n,m) grid. In each step Gorwin can go to right or down, i.e when Gorwin stands in (i,j), then she can go to (i+1,j) or (i,j+1) (However, she can not go out of the garden). nnWhen Gorwin reachs a grid, she can eat up the cake in that grid or just leave it alone. However she can’t eat part of the cake. But Gorwin’s belly is not very large, so she can eat at most K kilos cake. Now, Gorwin has stood in the top-left grid and look at the map of the garden, she want to find a route which can lead her to eat most cake. But the map is so complicated. So she wants you to help her.n nnInputnMultiple test cases (about 15), every case gives n, m, K in a single line.nnIn the next n lines, the i-th line contains m integers wi1,wi2,wi3,⋯wim which describes the weight of cakes in the i-th rownnPlease process to the end of file.nn[Technical Specification]nnAll inputs are integers.nn1<=n,m,K<=100nn1<=wij<=100n nnOutputnFor each case, output an integer in an single line indicates the maximum weight of cake Gorwin can eat.n nnSample Inputn1 1 2n3n2 3 100n1 2 3n4 5 6n nnSample Outputn0n16

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭