HDU2134 Cuts the cake【水题】

Cuts the cake

Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4196 Accepted Submission(s): 2673

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

Author
☆RPG♀月野兔☆

Source
HDU 2007-11 Programming Contest_WarmUp

问题链接HDU2134 Cuts the cake
问题简述:(略)
问题分析
    给定1个圆的半径,求另外2个半径,其圆将原有的圆面积三等分。一个水题。
程序说明:(略)
参考链接:(略)
题记:写水题的代码也要做到前无古人后无来者。

AC的C语言程序如下:

/* HDU2134 Cuts the cake */

#include <stdio.h>
#include <math.h>

#define PI 3.1415926

int main(void)
{
    double r, s, r1, r2;
    while(scanf("%lf", &r) != EOF && r) {
        s = PI * r * r;
        r1 = sqrt(s / 3.0 / PI);
        r2 = sqrt(s / 3.0 * 2.0 / PI);
        printf("%.3lf %.3lf\n", r1, r2);
    }

    return 0;
}

posted on 2019-01-07 21:03  新海岛Blog  阅读(105)  评论(0)    收藏  举报

导航

// ... runAll: function() { this.resetPreCode(); hljs.initHighlightingOnLoad(); // 重新渲染,添加语法高亮 hljs.initLineNumbersOnLoad(); // 为代码加上行号 } // ...