Fruit Ninja II

Time Limit: 5000MS Memory limit: 65536K

题目描述

Have you ever played a popular game named "Fruit Ninja"?



Fruit Ninja (known as Fruit Ninja HD on the iPad and Fruit Ninja THD for Nvidia Tegra 2 based Android devices) is a video game developed by Halfbrick. It was released April 21, 2010 for iPod Touch and iPhone devices, July 12, 2010 for the iPad, September 17,
2010 for Android OS devices. Fruit Ninja was well received by critics and consumers. The iOS version sold over 200,000 copies in its first month. By March 2011 total downloads across all platforms exceeded 20 million. It was also named one of Time magazine's
50 Best iPhone Apps of 2011.

"Swipe your finger across the screen to deliciously slash and splatter fruit like a true ninja warrior. Be careful of bombs - they are explosive to touch and will put a swift end to your juicy adventure!" - As it described on http://www.fruitninja.com/,
in Fruit Ninja the player slices fruit with a blade controlled via a touch pad. As the fruit is thrown onto the screen, the player swipes their finger across the screen to create a slicing motion, attempting to slice the fruit in parts. Extra points are awarded
for slicing multiple fruits with one swipe, and players can use additional fingers to make multiple slices simultaneously. Players must slice all fruit; if three pieces of fruit are missed the game ends. Bombs are occasionally thrown onto the screen, and will
also end the game should the player slice them.



Maybe you are an excellent player of Fruit Ninja, but in this problem we focus on something more mathematically. Consider a certain slicing trace you create on the touch pad, you slice a fruit (an apple or a banana or something else) into two parts at once.
Can you figure out the volume of each part?

Impossible task? Let us do some simplification by define our own Fruit Ninja game.

In our new Fruit Ninja game, only one kind of fruit will be thrown into the air - watermelon. What's more, the shape of every watermelon is a special Ellipsoid (details reachable at http://en.wikipedia.org/wiki/Ellipsoid) that it's polar radius OC is always
equals to it's equatorial radius OB. Formally, we can get this kind of solid by revolving a certain ellipse on the x-axis. And the slicing trace the player created (represented as MN in Illustration III) is a line parallel to the x-axis. The slicing motion
slice the watermelon into two parts, and the section (shown as the dark part in Illustration III) is parallel to plane x-O-y.



Given the length of OA, OB, OM (OM is the distance between the section and plane x-O-y), your task is to figure out the volume of the bigger part.

输入

There are multiple test cases. First line is an integer T (T ≈ 100), indicating the number of test cases.



For each test case, there are three integers: a, b, H, corresponding the length of OA, OB, OM. You may suppose that 0 < b <= a <= 100 and 0 <= H <= 100.

输出

Output case number "Case %d: " followed by a floating point number (round to 3) for each test case.

示例输入

4
2 2 0
2 2 1
2 2 2
2 2 3

示例输出

Case 1: 16.755
Case 2: 28.274
Case 3: 33.510
Case 4: 33.510

提示

 In case 4, H is larger than b, which simply represent a miss.

http://www.fruitninja.com/

http://en.wikipedia.org/wiki/Fruit_Ninja

http://en.wikipedia.org/wiki/Ellipsoid

来源

 2012年"浪潮杯"山东省第三届ACM大学生程序设计竞赛

解题思想:求半个椭球体积+从z=0到H的二重积分所求得的体积即答案。

注意:考虑到H有可能是大于b的,所以if(fabs(H)<fabs(b))H=fabs(H);else H=fabs(b);


#include <iostream>
#include <stdio.h>
#include <math.h>
#include<string.h>
#define PI acos(-1)
using namespace std;
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
double a,b,h;
cin>>a>>b>>h;
h=fabs(h);
if(h>fabs(b))h=fabs(b);
double s=0;
s=PI*a*b*h-PI*a*h*h*h/3.0/b;
s+=4*PI*b*b*a/6.0;
printf("Case %d: %.3lf\n",i,s);
}
return 0;
}

SDUT 2416:Fruit Ninja II的更多相关文章

  1. sdut 2416:Fruit Ninja II(第三届山东省省赛原题,数学题)

    Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...

  2. Sdut 2416 Fruit Ninja II(山东省第三届ACM省赛 J 题)(解析几何)

    Time Limit: 5000MS Memory limit: 65536K 题目描述 Haveyou ever played a popular game named "Fruit Ni ...

  3. hdu 4000 Fruit Ninja 树状数组

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4000 Recently, dobby is addicted in the Fruit Ninja. ...

  4. hdu 4620 Fruit Ninja Extreme

    Fruit Ninja Extreme Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  5. Fruit Ninja(树状数组+思维)

    Fruit Ninja Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  6. hdu4620 Fruit Ninja Extreme

    Fruit Ninja Extreme Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...

  7. Fruit Ninja(随机数rand())

    链接:https://www.nowcoder.com/acm/contest/163/A来源:牛客网 题目描述 Fruit Ninja is a juicy action game enjoyed ...

  8. Fruit Ninja(取随机数)

    链接:https://www.nowcoder.com/acm/contest/163/A来源:牛客网 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 262144K,其他语言524 ...

  9. Fruit Ninja

    Fruit Ninja 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 Fruit Ni ...

随机推荐

  1. Java基础之创建窗口——创建应用程序窗口(TryWindow)

    控制台程序. 准备好应用程序窗口及其包含的组件并显示,这称为实现窗口.调用应用程序窗口对象的setVisible()方法就会实现窗口.实现了应用程序的GUI之后,在主线程中修改或查询GUI可能会导致死 ...

  2. 几个PostgreSQL数据库操作总结

    创建表 语法:如下 create table     table_name     (column_name         column_type(parametes)options,…); 注意: ...

  3. 字典:NSDictionary的应用举例

    字典就是关键字及其定义(描述)的集合.Cocoa中的实现字典的集合NSDictionary在给定的关键字(通常是一个NSString)下存储一个数值(可以是任何类型的对象).然后你就可以用这个关键字来 ...

  4. nyist 626 intersection set

    http://acm.nyist.net/JudgeOnline/problem.php?pid=626 intersection set 时间限制:1000 ms  |  内存限制:65535 KB ...

  5. SQL查询 练习题

    设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1-2的表 ...

  6. 用C语言操纵Mysql

    以下代码块是用来连接数据库的通讯过程,要连接MYSQL,必须建立MYSQL实例,通过mysql_init初始化方能开始进行连接. typedef struct st_mysql { NET net; ...

  7. Demo13

    this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void o ...

  8. 记录下标准网线水晶头的做法 100m/1G

    注意, 网线分平行线(也叫直连线)和交叉线.  用法见下图 .也就是相同层内用交叉线, 不同层用平行线.  所以两台电脑,两台非级联并行的路由才用交叉线,一般我们都用平行线即可. 千兆网和百兆网不同: ...

  9. 统一使用GPT分区表,安装MAC 10.10 和 Win8.1 pro双系统

    步骤一: 为Mac OS 分区,为其它分区留白1,使用OSX Mavericks制作的Mac安装U盘按住Option键启动:2,选择安装Mavericks盘符:3,进入OSX安装启动界面,选择磁盘工具 ...

  10. Tomcat增加缓存