首页 > ACM题库 > HDU-杭电 > hdu 2134 Cuts the cake-计算几何-[解题报告]C++
2013
12-29

hdu 2134 Cuts the cake-计算几何-[解题报告]C++

Cuts the cake

问题描述 :

Ice cream took a bronze medal in the Beijing match. Liu sir is very very happy. So he buys a cake for them. kiki is a child who likes eating, so the task of cuting cake was given to kiki. kiki is also a mischievous child. She wants to cut the cake in a different way. This is introduced in the figure below.

But there is a difficult problem.which is how to make each preson get equally many cake. kiki is not good at match, so she wants you help her solve this problem.

输入:

Input contains multiple test cases. Each line is a case. Each case contains only one integer R which is the radius. The input is terminated with a R of 0.

输出:

Input contains multiple test cases. Each line is a case. Each case contains only one integer R which is the radius. The input is terminated with a R of 0.

样例输入:

10
15
5
25
0

样例输出:

5.774 8.165
8.660 12.247
2.887 4.082
14.434 20.412

点击打开链接

/*



水啊,可是WA了好几次,在计算总面积时不能用R*R,可能会超范围。。。

 

2013/01/22-09:22

*/

#include"stdio.h"
#include"math.h"
#define pi 3.1415926
int main()
{
	int r;
	double a,b,s;
	while(scanf("%d",&r)!=EOF)
	{
		if(r==0)break;
		s=pi;
		s=s/3;
		a=r*sqrt(s/pi);
		b=r*sqrt((s*2)/pi);
		printf("%.3f %.3f\n",a,b);
	}
	return 0;
}

解题转自:http://blog.csdn.net/yangyafeiac/article/details/8833055