NYOJ 1165 just a problem【计算几何】

题目链接

#include<stdio.h>
#include<math.h>

struct point
{
	double x;
	double y;
}circle,a,b,c,d,temp;

double r;

double dis(point &a,point &b)
{
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

int main()
{
	int s,t;
	scanf("%d",&s);
	while(s--)
	{
		scanf("%lf%lf%lf",&circle.x,&circle.y,&r);
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y);
		if(a.x > c.x)
		{
			temp=a;
			a=c;
			c=temp;
		}
		if(dis(a,circle)<r && dis(b,circle)<r && dis(c,circle)<r && dis(d,circle)<r)
		{
			printf("No!\n");
			continue;
		}
		if(circle.x >= a.x && circle.x <= c.x)
		{
			if(fabs(circle.y - a.y) <= r || fabs(circle.y - c.y) <= r)
			{
				printf("Yes!\n");
				continue;
			}
		}
		if((circle.y >= a.y && circle.y <= b.y) || (circle.y >= b.y && circle.y <= a.y))
		{
			if(fabs(circle.x - a.x) <= r || fabs(circle.x - c.x) <= r)
			{
				printf("Yes!\n");
				continue;
			}
		}
		if(dis(a,circle)<=r || dis(b,circle)<=r || dis(c,circle)<=r || dis(d,circle)<=r)
		{
			printf("Yes!\n");
			continue;
		}
		printf("No!\n");
	}
	return 0;
}
http://blog.csdn.net/sunrain_chy/article/details/9492801
时间: 2024-10-31 18:26:27

NYOJ 1165 just a problem【计算几何】的相关文章

NYOJ 179 LK&#39;s problem (排序模拟)

链接:click here~~ 题意: 描述 LK has a question.Coule you help her? It is the beginning of the day at a bank, and a crowd  of clients is already waiting for the entrance door to  open. Once the bank opens, no more clients arrive, and  tellerCount tellers be

NYOJ 698 A Coin Problem (斐波那契)

链接:click here 题意: 描述 One day,Jiameier is tidying up the room,and find some coins. Then she throws the coin to play.Suddenly,she thinks of a problem ,that if throw n times coin ,how many situations of no-continuous up of the coin. Hey,Let's solve the

NYOJ 707 A Simple Problem(结构体排序) 睡前一水~~

链接:click here 题意: A Simple Problem 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述 You know, just as the title imply, this is a simple problem. In a contest, given the team-id, solved, penalty of all the teams, tell me the champion.If the numbers of solved pr

nyoj 513 A+B Problem IV 【Java大数】

这道题有点小坑.. 特殊数据 输入 0.0 0.0 输出 0 代码: import java.util.Scanner; import java.math.*; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); BigDecimal a, b, temp; temp = new BigDecimal("0.0"); while(cin.hasN

nyoj 803 A/B Problem 【Java大数】

 先用字符串将字符串接收,然后在用BigInteger就好了 代码: import java.util.Scanner; import java.math.*; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); while(cin.hasNextBigInteger()){ BigInteger aa, bb; //a = cin.nextBigDeci

nyoj 1235 A/B Problem

A/B Problem 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 已知: 1. n = (A % 9973); 2. gcd(B, 9973) = 1; 计算: (A / B) % 9973 输入 数据的第一行是一个T,表示有T组数据.每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9). 输出 对应每组数据输出(A / B) % 9973. 样例输入 2 1000 53 87 123456789 样例输出 792

NYOJ 477 A+B Problem III(认识fabs函数)

 A+B Problem III 时间限制:1000 ms  |  内存限制:65535 KB 难度:1 描述 求A+B是否与C相等. 输入 T组测试数据. 每组数据中有三个实数A,B,C(-10000.0<=A,B<=10000.0,-20000.0<=C<=20000.0) 数据保证小数点后不超过4位. 输出 如果相等则输出Yes 不相等则输出No 样例输入 3 -11.1 +11.1 0 11 -11.25 -0.25 1 2 +4 样例输出 Yes Yes No 刚开始

POJ 2826 An Easy Problem?!(计算几何)

An Easy Problem?! Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10533   Accepted: 1589 Description It's raining outside. Farmer Johnson's bull Ben wants some rain to water his flowers. Ben nails two wooden boards on the wall of his bar

NYoj The partial sum problem(简单深搜+优化)

题目链接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=927 代码: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <math.h> 5 #include <algorithm> 6 #include <iostream> 7 using namespace std; 8