Sdut 2416 Fruit Ninja II (question J of the third ACM competition in Shandong province) (analytic ry)

Source: Internet
Author: User

Time Limit: 5000 Ms memory limit: 65536 K

Description

 

Haveyou ever played a popular game named "Fruit Ninja "?

Fruit Ninja (known as fruit ninja HD on the iPad and Fruit Ninja thd for nvidiategra 2 based Android devices) is a video game developed by halfbrick. it wasreleased rjl 21,201 0 for iPod Touch and iPhone devices, July 12,201 0 forthe iPad, September 17,201 0 for Android OS devices. fruit Ninja was wellreceived by critics and consumers. the IOS version sold over 200,000 copies inits first month. by March 2011 total downloads internal SS all platforms exceeded 20million. it was also named one of time magazines's 50 best iPhone apps of 2011.


 

 

"Swipeyour finger implements ss the screen to deliciously slash and splatter fruit like atrue ninja warrior. Be careful of bombs-they are explosive to touch and willput a swift end to your juicy adventure! "-As it described onhttp: // www.fruitninja.com/, in Fruit Ninja the player slices fruit with a bladecontrolled via a touch pad. as the fruit is thrown onto the screen, the player swipestheir finger implements ss the screen to create a slicing motion, attempting to slicethe fruit in parts. extra points are awarded for slicing multiple fruits withone swipe, and players can use additional fingers to make multiple slicessimultaneously. players must slice all fruit; if three pieces of fruit aremissed the game ends. bombs are occasionally thrown onto the screen, and willalso end the game shoshould the player slice them.

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

 

 

Impossibletask? 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 polarradius OC is always equals to it's equatorial radius ob. formally, We Can getthis kind of solid by revolving a certain ellipse on the x-axis. and theslicing trace the player created (represented as Mn in authentication III) is Aline parallel to the x-axis. the slicing motion slice the watermelon into twoparts, and the section (shown as the dark part in registration III) is parallelto plane x-o-y.

Given the length of OA, ob, OM (OM is thedistance between the Section and plane x-o-y), your task is to figure out thevolume of the bigger part.

 

Input

Thereare multiple test cases. First line is an integer T (t ≈ 100), indicating thenumber of test cases.

For each test case, there are three integers: A, B, H, corresponding the lengthof OA, ob, Om. you may Suppose that0 <B <= A <= 100 and 0 <= H <= 100.

Output

Outputcase number "case % d:" followed by a floating point number (round to3) for each test case.

Demo Input

4

2 2 0

2 2 1

2 2 2

2 2 3

Demo output

Case 1: 16.755

Case 2: 28.274

Case 3: 33.510

Case 4: 33.510


The time is urgent and the image processing is not very good. Let's take a look.

/***********************

I was scared to read this question. After reading it carefully, you will find that this is a problem of triple points on a high number.

The lack of elliptical volume test: http://zhidao.baidu.com/link? Url = vgl0sarergv86msyl9wiljwfmk29d -- x2frRo0pNEkRoY7-3K2r5sbL-aR15Vcd_VwKLU2xpmEMFUgGVq7SI1K

Elliptical long half-axis A, short half-axis B, high H (H is the H in the question)

The size of the elliptical lacks can be calculated as follows: (the mathematical symbols in Word cannot be displayed. Cut an image)

Pi is the circumference Rate


Then, you can use this volume to add the volume of the hemisphere ..

Formula: V = 2/3 * pI * a * B + pI * a * (B * H-H ^ 3/(3 * B ))

Code:

# Include <iostream> # include <stdio. h> using namespace STD; const double Pi = 3.14159265358; // Pi = 3.1415926535 When Wa, so pay attention to the precision int main () {int T, Count = 1; Double, b, H, V; scanf ("% d", & T); While (t --) {scanf ("% lf", & A, & B, & H); If (h> = B) H = B; V = 2.0/3.0 * pI * a * B + pI * a * B * H-Pi * a * H/(3.0 * B ); printf ("case % d:", Count ++); printf ("%. 3lf \ n ", V);} return 0 ;}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.