HDOJ题目地址:传送门
Cuts the cake
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3318 Accepted Submission(s): 2099
Problem Description
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
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.
Output
For each test case, you should printf two numbers r2 and r1 in a line, accurate up to 3 decimal places, separate them by one space.
Sample Input
Sample Output
5.774 8.165
8.660 12.247
2.887 4.082
14.434 20.412
题意:将蛋糕分成三份,求 r1 和 r2 ,根据三份蛋糕面积相等得出两个公式,很简单
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main(){
int n;
double PI=3.1415926,r1,r2,R;
while(scanf("%d",&n)&&n){
R=n;
r2=R/sqrt(3);
r1=(sqrt(2)/sqrt(3))*R;
printf("%.3lf %.3lf\n",r2,r1);
}
}