【百炼oj】1675:Happy Birthday!

2023-10-24 18:58
文章标签 oj birthday happy 1675 百炼

本文主要是介绍【百炼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;}
}

这篇关于【百炼oj】1675:Happy Birthday!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/277125

相关文章

CF629D Babaei and Birthday Cake

题意:给出N个半径,和高的圆柱,要求后面的体积比前面大的可以堆在前一个的上面,求最大的体积和。 dp[i]=max(dp[j])+v[i](j<i&&v[i]>v[j]); 离散化,线段树维护区间最大值 import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import

哈理工OJ 2179(深搜)

组合 Time Limit: 1000 MSMemory Limit: 32768 K Total Submit: 7(5 users)Total Accepted: 6(5 users)Rating: Special Judge: No Description 给出一个正整数N,从集合{1,2,3..N} 中找出所有大小为k的子集, 并按照字典序从小到大输出。 Input 第一行是一个整

每日OJ_牛客_求和(递归深搜)

目录 牛客_求和(递归深搜) 解析代码 牛客_求和(递归深搜) 求和_好未来笔试题_牛客网 解析代码         递归中每次累加一个新的数,如果累加和大于等于目标,结束递归。此时如果累加和正好等于目标,则打印组合。向上回退搜索其它组合。此题本身就是一个搜索的过程,找到所有的组合。 #include <iostream>#include <cmath>#in

OJ-0905

题目 示例1: 输入:10 10 56 34 99 1 87 8 99 3 255 6 99 5 255 4 99 7 255 2 99 9 255 213 4输出:99 示例2: 输入:10 10 255 34 0 1 255 8 0 3 255 6 0 5 255 4 0 7 255 2 0 9 255 213 5输出:255 import java.util.

每日OJ_牛客_Emacs计算器(逆波兰表达式)

目录 牛客_Emacs计算器(逆波兰表达式) 解析代码 牛客_Emacs计算器(逆波兰表达式) Emacs计算器__牛客网 解析代码 逆波兰表达式(后缀表达式)求值,需要借助栈,思路: 循环输入,获取逆波兰表达式,然后进行以下补助,直到测试完所有的测试用例: 遇到数字字符串,将该数字字符串转化为数字然后入栈。遇到操作符时,从栈顶取两个数字,然后进行该运算符所对应运算

西北工业大学oj题-兔子生崽

题目描述: 兔子生崽问题。假设一对小兔的成熟期是一个月,即一个月可长成成兔,每对成兔每个月可以生一对小兔,一对新生的小兔从第二个月起就开始生兔子,试问从一对兔子开始繁殖,一年以后可有多少对兔子? 这道题目一眼看过去就是典型的递归问题,代码如下 public class RabbitReproduction {public static void main(String[] args) {in

★ 算法OJ题 ★ 力扣209 - 长度最小的子数组

Ciallo~(∠・ω< )⌒☆ ~ 今天,简将和大家一起做一道滑动窗口算法题--长度最小的子数组~ 目录 一  题目 二  算法解析 解法⼀:暴力求解 解法二:滑动窗口 三  编写算法 一  题目 209. 长度最小的子数组 - 力扣(LeetCode) 二  算法解析 解法⼀:暴力求解 算法思路: 从前往后枚举数组中的任意⼀个元素,把它当成起始位置

OJ-0903

题目 示例1 输入:30 12 25 8 19输出:15 示例2 输入:10 12 25 8 19 8 6 4 17 19 20 30输出:-1 题解 import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class Main {public static

【负载均衡式在线OJ】Compile_server 模块

文章目录 程序源码compile_server整体思路编译(compile.hpp)运行模块编译运行模块编译运行服务 程序源码 https://gitee.com/not-a-stupid-child/online-judge compile_server 整体思路 这个服务要对oj_server 发送过来的代码进行编译和运行,最后把结果返回给oj_server。 所以我

★ 算法OJ题 ★ 力扣18 - 四数之和

Ciallo~(∠・ω< )⌒☆ ~ 今天,爱丽速子将和大家一起做一道双指针算法题--四数之和~ 目录 一  题目 二  算法解析 三  编写算法  做此题前最好先看一下前两篇博客~: ★ 算法OJ题 ★ 力扣 LCR179 - 和为 s 的两个数字-CSDN博客 ★ 算法OJ题 ★ 力扣15 - 三数之和-CSDN博客 一  题目 18. 四数之和 - 力扣(Lee