URAL - 1793 Tray 2(几何题)

Tray 2

Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

One of the organizers of the Ural Regional School Programming Contest came to the university cafeteria to have lunch. He took a soup and a main course and tried to arrange them on a small rectangular tray, which was not so easy.
“Oops, that‘s a problem,” he thought. “Oh, yes, that‘s a problem! A nice problem for the contest!”

The Ural State University‘s cafeteria has trays with a rectangular a × b bottom and vertical borders of height d. Plates have the shape
of a truncated cone. All the plates in the cafeteria have the same height h. The organizer wants to put the plates on the tray so that their bottoms adjoin the bottom of the tray completely. Can he do it?

Input

The first line contains the integers ab, and d separated with a space. Each of the following lines describes one of the plates and contains two
integers. The former integer is the radius of the plate‘s bottom and the latter integer is the radius of the circle formed by the edge of the plate. The second radius is greater than the first one. The last line contains the height h of
the plates. All the input integers are positive and do not exceed 1000.

Output

Output “YES” if the plates can be arranged on the tray and “NO” otherwise.

Sample Input

input output
10 10 10
1 2
1 2
5
YES
8 4 1
1 2
1 3
1
NO

以前做过类似的题,只是把二维的问题搬到空间上来,处理出与托盘接触的平面中,碗的截面就好了,两个圆分别放在两个边角,判断距离与大半径的关系就好了。

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const double esp = 0.00001;
struct Point
{
	double x;
	double y;
	Point(double xx, double yy) :x(xx), y(yy){}
};
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()
{
	double a, b, d;
	double r1, R1, r2, R2, h;
	double rr1, rr2;

	while (cin >> a >> b >> d)
	{
		cin >> r1 >> R1;
		cin >> r2 >> R2;
		cin >> h;
		rr1 = r1*(h - d) / h + R1*d / h;
		rr2 = r2*(h - d) / h + R2*d / h;
		if (h <= d)
		{
			rr1 = R1;
			rr2 = R2;
		}
		if (2 * rr1 > a || 2 * rr1 > b|| 2 * rr2 > a || 2 * rr2 > b)
		{
			cout << "NO" << endl;
			continue;
		}
		Point p1(rr1, rr1);
		Point p2(a - rr2, b - rr2);
		double dd = dis(p1, p2);
		if (dd >= R1 + R2)
		{
			cout << "YES" << endl;
		}
		else
			cout << "NO" << endl;
	}
}
时间: 2024-10-07 16:25:24

URAL - 1793 Tray 2(几何题)的相关文章

3.7 CSS中的几何题

经过前面的学习.对标准流中的盒子排列方式应该已经很清楚了,下面来做一个习题. 假设有一个网页,其显示结果如图1所示,现在要读者精确地回答出从字母a到x对应的宽度是多少个像素.习题文件位于网页学习网CSS教程资源“第3章\04.htm”. 图1 计算图中各个字母代表的宽度(高度)是多少像素 网页的完整代码如下:lodidance.com <!DOCTYPE html PUBliC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http

数学5. 一道几何题

大连北纬39°,北回归线纬度为23.5°. 在夏至时,太阳直射北回归线. 请问:此时在大连太阳落山时是西偏南,还是西偏北?多少度? 数学5. 一道几何题,布布扣,bubuko.com

cdoj 93 King&#39;s Sanctuary 傻逼几何题

King's Sanctuary Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/93 Description The king found his adherents were building four sanctuaries for him. He is interested about the positions of the sanctuaries and want

[Swust OJ 771]--奶牛农场(几何题,画图就好)

题目链接:http://acm.swust.edu.cn/problem/771/   Description 将军有一个用栅栏围成的矩形农场和一只奶牛,在农场的一个角落放有一只矩形的箱子,有一天将军要出门,他就把奶牛用一根绳子套牢,然后将绳子的另一端绑到了那个箱子不靠栅栏的角上,现在给定箱子的长和宽,绳子的长度,你的问题是计算奶牛能够到达的面积. Input 有多组测试数据. 每一组数据为一行,三个整数,L(0<=L<=500),M,N(1<=M,N<=500),分别表示绳子的长

ural 1297 Palindrome(Manacher模板题)

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 求最长回文子串. http://acm.timus.ru/problem.aspx?space=1&num=1297 Manacher模板题,复杂度O(n),做这题纯属是为了验一下自己写的模板是否正确. 当然这题也可以用后缀数组来搞 1 #include <iostream> 2 #include <sstream> 3 #include <ios&g

URAL - 1823 Ideal Gas(审题)

Ideal Gas Time Limit: 500MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status Description Many of you know the universal method of solving simple physics problems: you have to find in a textbook an identity in which you know the

MT【282】一道几何题

2010浙江省数学竞赛,附加题. 设$D,E,F$分别为$\Delta ABC$的三边$BC,CA,AB$上的点,记$\alpha=\dfrac{BD}{BC},\beta=\dfrac{BD}{BC},\gamma=\dfrac{AF}{AB}$ 证明:$S_{\Delta DEF}\ge\alpha\beta\gamma S_{\Delta ABC}$ 证明:$S_{DEF}=S_{ABC}-S_{AFE}-S_{BDF}-S_{DCE}$$=S_{ABC}(1-\sum\limits_{c

纯几何题 --- UVA - 11646 Athletics Track

这一题题目有点坑,注意这句话: 这代表了其圆心就是矩形的中心! 然后就可以推公式: 可知: x = 200/(a+2atan(b/c)*r); r = sqrt(a*a + b*b); 所以有AC代码如下: #include <iostream> #include <cstdio> #include <cmath> using namespace std; int main() { int k = 0; double a, b; while(scanf("%l

POJ 1328 Radar Installation#贪心(坐标几何题)

(- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; struct node { double l,r; //找到以岛为圆心,以d为半径的圆与坐标x轴的左交点l.右交点r //雷达只有设在l~r之间,岛才在雷达覆盖范围内 }a[1005]; int cmp(node a,node b) { return a.l