地址: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; }