HDU 2368 Alfredo's pizza restaurant (simple mathematical problem)

Source: Internet
Author: User
Tags integer numbers

Reprinted please indicate the source: http://blog.csdn.net/u012860063

Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2368


The question is very simple, but it is quite disgusting. It won't take a second to die when SQRT Wa is used;

I can't help but vomit;


Problem descriptiontraditionally after the local contest, judges and contestants go to their favorite restaurant, alfredos pizza restaurant. the contestants are really hungry after trying hard for five hours. to get their pizza as quickly as possible, they just decided to order one big pizza for all instead of several small ones. they wonder whether it is possible to put the big rectangular pizza On the surface of the Round Table such that it does not overhang the border of the table. Write a program that helps them!
Inputthe input file contains several test cases. each test case starts with an integer number R, the radius of the surface of the round table the contestants are sitting. input is terminated by r = 0. otherwise, 1 ≤ r ≤ 1000. then follow 2 integer numbers W and l specifying the width and length of the pizza, 1 ≤ W ≤ L ≤ 1000.
Outputoutput for each test case whether the ordered pizza will fit on the table or not. adhere to the format shown in the sample output. A pizza which just touches the border of the table without intersecting it is considered fitting on the table, see Example 3 for clarification.
Sample Input
38 40 6035 20 7050 60 800
Sample output
Pizza 1 fits on the table.Pizza 2 does not fit on the table.Pizza 3 fits on the table.


Source2008 open water competition (comparison speed, OJ stress testing)


Note: fit is not suitable, and fits is suitable;

The Code is as follows:

#include <cstdio>int main(){int cas = 0;int r, w, l;while(scanf("%d",&r) && r){scanf("%d%d",&w,&l);printf("Pizza %d ",++cas);if(4*r*r-w*w < l*l){printf("does not fit on the table.\n");}elseprintf("fits on the table.\n");}return 0;}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.