码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 2134 Cuts the cake

时间:2018-08-03 00:59:42      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:panel   targe   tip   out   one   return   dal   output   bre   

http://acm.hdu.edu.cn/showproblem.php?pid=2134

 

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
10
15
5
25
0
 
Sample Output
5.774 8.165
8.660 12.247
2.887 4.082
14.434 20.412
 
代码:
#include <bits/stdc++.h>
using namespace std;

int main() {
    double R;
    while(cin >> R) {
        if(R == 0)
            break;
            
        double r1, r2;
        r1 = sqrt(R * R / 3.0);
        r2 = sqrt(R * R * 2.0 / 3.0);
        
        printf("%.3lf %.3lf\n", r1, r2);
    }
    return 0;
}

  

HDU 2134 Cuts the cake

标签:panel   targe   tip   out   one   return   dal   output   bre   

原文地址:https://www.cnblogs.com/zlrrrr/p/9410864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!