HDOJCuts the cake
来源:互联网 发布:汽车金融软件 编辑:程序博客网 时间:2024/06/16 16:44
Cuts the cake
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3890 Accepted Submission(s): 2476
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.
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
10155250
Sample Output
5.774 8.1658.660 12.2472.887 4.08214.434 20.412
import java.util.Scanner;public class Main{ private static Scanner scanner; public static void main(String[] args) { scanner = new Scanner(System.in); while(scanner.hasNext()){ int R = scanner.nextInt(); if(R == 0){ break; } double s = Math.PI*R*R; double r1 = Math.sqrt((2.0/3*s)/Math.PI); double r2 = Math.sqrt((1.0/3*s)/Math.PI); System.out.printf("%.3f %.3f",r2,r1); System.out.println(); } }}// WA:// double r1 = Math.sqrt(2.0/3*R*R);// double r2 = Math.sqrt(R*R/3.0);// 不能直接推导公式(不能把PI约去)
阅读全文
0 0
- HDOJCuts the cake
- hoj2134 Cuts the cake
- HDU2134:Cuts the cake
- Cuts the cake
- hdu4762 Cut the Cake
- [概率]Cut the Cake
- Cut The Cake
- 锦上添花 Icing on the cake
- pku1624 This Takes the Cake
- JOJ2026:Divide the Birthday Cake
- pku 3587 The Biggest Cake
- HDU 4328 - Cut the cake
- hdu 4328 Cut the cake
- hdu 4328 Cut the cake
- Cuts the cake +面积相等
- hdu-2134-Cuts the cake
- hdu 4328 Cut the cake
- HDU-4328-Cut the cake
- 用邻接表存储有向图实现的dfs和bfs
- SVG 新司机开车指南
- contos7 使用yum快速 搭建lnmp 环境
- 软件调试笔记21
- Linux文件管理
- HDOJCuts the cake
- 【全网首发】Tomcat配置“X-Frame-Options头未设置”警告的过滤器(详细)
- c 语言 从字符串中取出一串单词并倒序
- POJ 2367---Genealogical tree(拓扑排序基础题)
- 《C++ Primer(第5版)》习题答案
- java运算符的优先级
- JS生成随机数
- 如何让应用支持 Android 8.0 自动填充?
- 【功能代码】---1.通过Jquery来处理复选框