hdu 2368 Alfredo's Pizza Restaurant(简单数学题)

转载请注明出处:http://blog.csdn.net/u012860063

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2368

题目很简单,但是比较恶心,用sqrt WA到死也不过,不用秒过;

忍不住吐槽一下;

Problem Description

Traditionally after the Local Contest, judges and contestants go to their favourite 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!

Input

The 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 at. Input is terminated by r=0. Otherwise, 1 ≤ r ≤ 1000. Then follow
2 integer numbers w and l specifying the width and the length of the pizza, 1 ≤ w ≤ l ≤ 1000.

Output

Output 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 60
35 20 70
50 60 80
0

Sample Output

Pizza 1 fits on the table.
Pizza 2 does not fit on the table.
Pizza 3 fits on the table.

Source

2008水题公开赛(比速度,OJ压力测试)

注意,不合适的时候是fit,合适的时候是fits;

代码如下:

#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");
		}
		else
			printf("fits on the table.\n");
	}
	return 0;
}

hdu 2368 Alfredo's Pizza Restaurant(简单数学题),布布扣,bubuko.com

hdu 2368 Alfredo's Pizza Restaurant(简单数学题)

时间: 2024-08-02 11:04:45

hdu 2368 Alfredo's Pizza Restaurant(简单数学题)的相关文章

HDU - 2368 Alfredo&#39;s Pizza Restaurant

题意:判断一个长方形是否能放到一个圆形里. 分析:将长方形的一条边贴近圆放置,求另一条边的最长长度lmax,若l<=lmax,则能放置. 注意:若这条边的长度大于直径,则一定不能放到圆里.因此,在求lmax的时候,在保证是非负数的情况下才能sqrt. #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<cmath> #include&l

HDU 1326 Box of Bricks(简单数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1326 Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. ``Look, I've built a wall!'', he tells his older siste

HDU - 2058 The sum problem(简单数学题)

题意:求出所有的情况,等差上去可以达到m值. 原来想着暴力搜索,但是题中的数据太大,所以时间超限. 百度了一下,发现可以套公式. 等差求和公式: Sn=(a1+aN)*n/2     =(a1+a1+d(n-1))*n/2     =a1*n+d(n-1)*n/2; 因为此处公差d=1,所以Sn=a1*n+(n-1)*n/2,当从第一项开始算起时(因本题首项为1,即a1=1时),Sn=M时的项的个数n最多; a1=1,现在又可化简为Sn=n+(n-1)*n/2=(n+1)n/2; 由题意得M=S

HDU 6467 简单数学题 【递推公式 &amp;&amp; O(1)优化乘法】(广东工业大学第十四届程序设计竞赛)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6467 简单数学题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 308    Accepted Submission(s): 150 Problem Description 已知 F(n)=∑i=1n(i×∑j=inCij) 求 F(n) m

hdu2374 A Game with Marbles(简单数学题)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2374 Problem Description There are n bowls, numbered from 1 to n. Initially, bowl i contains mi marbles. One game step consists of removing one marble from a bowl.

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

HDU 1038[Biker&#39;s Trip Odometer]简单计算

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1038 题目大意:给轮子直径,转数,时间.要求输出走过的距离和时速(mile为单位) 关键思想:纯算 代码如下: #include <iostream> using namespace std; #define pi 3.1415927 int main(){ double d,r,t,l; int cnt=1; while(cin>>d>>r>>t&&a

[HDU 4082] Hou Yi&#39;s secret (简单计算几何)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4082 题目大意: 给你n个点,问能最多构成多少个相似三角形. 用余弦定理,计算三个角度,然后暴力数有多少个,更新答案. 代码: 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4 #include <cstring> 5 #include <vector> 6 #includ

HDU ACM 1103 Flo&#39;s Restaurant

分析:借助STL的min_element实现.每次更新最先被占用的桌子,具体见注释. #include<iostream> #include<algorithm> using namespace std; int main() { int A,B,C; char s[10]; int a[102],b[102],c[102]; int curtime,count,ans; int *p; //桌子最先空闲时间 while(cin>>A>>B>>C