zoukankan      html  css  js  c++  java
  • Cuts the cake_hdu_2134.java

    Cuts the cake

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

    Total Submission(s): 2202    Accepted Submission(s): 1354

    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
     
     
    import java.util.Scanner;
    
    public class Main{
    	public static void main(String[] args) {
    		Scanner input=new Scanner(System.in);
    		while(true){
    			int r=input.nextInt();
    			if(r==0)
    				break;
    			double sum=Math.PI*r*r;
    			double R=sum/3;
    			double r1=Math.sqrt(R/Math.PI);
    			double r2=Math.sqrt(2*R/Math.PI);
    			System.out.println(String.format("%.3f %.3f", r1,r2));
    		}
    	}
    }


  • 相关阅读:
    odoo 自定义视图
    Odoo 模型之间的关系 笔记
    C#中计算两点之间连线的角度
    Jquery中1.6.x中新的方法prop()方法
    VS2010快捷键说明
    将DATAtable转换成 json格式
    在IIS中执行EXE文件时的问题
    WebDev.WebServer40.exe已停止工作
    sqllite developer过期解决方案
    c#的DateTime.Now函数详解
  • 原文地址:https://www.cnblogs.com/pangblog/p/3265411.html
Copyright © 2011-2022 走看看