andre_joy

导航

hdu 2368

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2368

题意:判断一个正方形的pizza能否放在一个圆形的桌子上,使得pizza没有地方不接触桌子。

mark:正方形对角线/2跟圆半径比较。

代码:

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

int main()
{
    int r,w,l,i;
    double d;
    i = 1;
    while(scanf("%d", &r), r)
    {
        scanf("%d%d", &w, &l);
        d = sqrt(w*w+l*l)/2;
        printf("Pizza %d ", i++);
        puts((d <= 1.0*r) ? "fits on the table." : "does not fit on the table.");
    }
    return 0;
}

posted on 2012-07-03 17:56  andre_joy  阅读(98)  评论(0)    收藏  举报