Fruit Ninja II(山东省第三届ACM大学生程序设计竞赛 )
来源:互联网 发布:yum install gcc 失败 编辑:程序博客网 时间:2024/06/05 21:04
Problem Description
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.
Input
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
Output case number "Case %d: " followed by a floating point number (round to 3) for each test case.
Example Input
42 2 02 2 12 2 22 2 3
Example Output
Case 1: 16.755Case 2: 28.274Case 3: 33.510Case 4: 33.510
公式: V = 2/3*PI*a*b*b+PI *a*(b*h—h^3/(3*b))
#include <iostream>#include <stdio.h>#include <cmath>using namespace std;//椭圆体的体积V= 4/3πabc (a与b,c分别代表各轴的一半)int main() //题目中已知 b ,c 相等{ int T; scanf("%d",&T); int i; for(i=1; i<=T; i++) { int a,b,h; scanf("%d%d%d",&a,&b,&h); double V; V=(4.0/3)*M_PI*a*b*b; if(h>=b) { printf("Case %d: %.3lf\n",i,V); } else { double v=M_PI*a*b*(b-h)-M_PI*(1.0*a/b)*(1.0/3)*(b*b*b-h*h*h); if(V - 2*v >0) printf("Case %d: %.3lf\n",i,V-v); else printf("Case %d: %.3lf\n",i,v); } } return 0;}
- 山东省第三届ACM大学生程序设计竞赛 Fruit Ninja II
- Fruit Ninja II(山东省第三届ACM大学生程序设计竞赛 )
- [2012山东省第三届ACM大学生程序设计竞赛]——Fruit Ninja II
- 2012年"浪潮杯"山东省第三届ACM大学生程序设计竞赛——Fruit Ninja II
- 山东省第三届ACM大学生程序设计竞赛 Fruit Ninja I(01背包)
- 第三届山东省ACM Fruit Ninja II
- 2013山东省第三届ACM省赛 Fruit Ninja II
- 山东省第三届ACM大学生程序设计竞赛(待添加)
- Pick apples(山东省第三届ACM大学生程序设计竞赛)
- Sdut 2416 Fruit Ninja II(山东省第三届ACM省赛 J 题)(解析几何)
- 山东省第三届ACM大学生程序设计竞赛 n a^o7 !
- 山东省第五届ACM大学生程序设计竞赛-Hearthstone II(组合数学-第二类Stirling数)
- 2014年山东省第五届ACM大学生程序设计竞赛--Hearthstone II(第一类Stirling数)
- 山东省第七届ACM大学生程序设计竞赛
- 第四届 山东省ACM大学生程序设计竞赛
- 第七届 山东省ACM大学生程序设计竞赛
- Mine Number(2012年"浪潮杯"山东省第三届ACM大学生程序设计竞赛)
- 山东省第三届ACM大学生程序设计竞赛-Pixel density(模拟)
- 第二章 逻辑代数基础
- POJ2378【树形DP】
- 程序员日常工作英文20170523
- ubuntu14.04安装CPU版SSD(Single Shot MultiBox Detector)/Caffe版本
- hdoj1024 Max Sum Plus Plus (DP)
- Fruit Ninja II(山东省第三届ACM大学生程序设计竞赛 )
- 初始三层
- matlab中对矩阵进行排序
- markdown编辑器使用方法
- 机器学习教程之4-正则化(Regularization)
- Linux下系统时间函数--->gettimeofday
- jquery.min.js:2 Uncaught RangeError: Maximum call stack size exceeded
- Kotlin笔记(一)简介
- 22.struts2_运行流程分析