首页 > 其他分享 >HDOJCuts the cake

HDOJCuts the cake

时间:2023-02-20 10:37:15浏览次数:21  
标签:r1 double HDOJCuts kiki cake PI Math


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.


HDOJCuts the cake_Math


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{
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约去)


标签:r1,double,HDOJCuts,kiki,cake,PI,Math
From: https://blog.51cto.com/u_15741949/6067721

相关文章

  • 详解Cake Pattern in rocket-chip
    下面分别对cakepattern中的关键概念进行说明,最后以chipyard为例对cakepattern的用法进行说明,cakepattern对Diplomacy机制至关重要。一、LazyModule定义惰性模块,实现......
  • C - Cake HDU - 1722 (数学)
    题意:就是一个蛋糕,被分成n或者m份。问最少动几刀。看一下这个图,就知道公式了,n+m-gcd(n,m);#include<cstdio>#include<iostream>usingnamespacestd;#definelllon......
  • C - Cake HDU - 1722 (数学)
    题意:就是一个蛋糕,被分成n或者m份。问最少动几刀。看一下这个图,就知道公式了,n+m-gcd(n,m);#include<cstdio>#include<iostream>usingnamespacestd;#definelllon......
  • C - Cake HDU - 1722 (数学)
    题意:就是一个蛋糕,被分成n或者m份。问最少动几刀。看一下这个图,就知道公式了,n+m-gcd(n,m);#include<cstdio>#include<iostream>usingnamespacestd;#definelllon......
  • CakePHP 2.x十分钟博客教程(一):安装与配置
     Cakephp2.0依然保持着Cakephp框架的各种优良传统,其中之一就是非常易于新手入门,几乎不做任何复杂的配置即可使用。非常可惜的是,Cakephp2.0手册竟然没有了中文翻译,1.3的翻......
  • cakephp学习3
    1数据库表的设计要根据cakephp的规范.比如表名要以小写+复数的形式,如books.如果是两个单词的话,要这样.author_name,用下划线分开.2每个表必须有主键id 3model的文件名......
  • cakephp 学习2
    1cakephp中,control层自动按其命名去寻找model层,比如按TaskController,则关联Task的这个model如果不关联,可以这样<?phpclassBooksControllerextendsAppController{......
  • cakephp 学习1
    1安装配置  下载1.2的版本吧,之后解压2在httpd.conf中设置  <Directory"f:/myphp5/cakephp">OptionsIndexesFollowSymLinksAllowOverrideallOrderDeny,All......
  • cakephp中加载第三方类的一点注意的
    在cakephp中,加载其他不相关的类,有三种方法,例子如下:<?phpclassTasksControllerextendsAppController{var$name='Tasks';functionin......
  • 在CakePHP中使用TinyMCE编辑器【转】
    ​​TinyMCEEditor​​​小巧实用,是网页文章编辑器之首先,最近在用CakePHP做一个小项目正好用到,记录一下。首先下载​​​TinyMCE​​,并把压缩包内tinymce/jscripts/tiny......