设为首页 加入收藏

TOP

URAL - 1793 Tray 2(几何题)
2015-11-21 01:04:25 来源: 作者: 【 】 浏览:1
Tags:URAL 1793 Tray 几何
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? Problem illustration

Input

The first line contains the integers a, b, 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
  
   
#include
   
     #include
    
      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; } }
    
   
  


?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇STL upper_bound(),lower_bound().. 下一篇pku3090 Visible Lattice Points..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: