日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[2012山东ACM省赛] Fruit Ninja II (三重积分,椭球体积)

發(fā)布時(shí)間:2023/12/14 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [2012山东ACM省赛] Fruit Ninja II (三重积分,椭球体积) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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.

示例輸入

42 2 02 2 12 2 22 2 3

示例輸出

Case 1: 16.755Case 2: 28.274Case 3: 33.510Case 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大學(xué)生程序設(shè)計(jì)競(jìng)賽

?

解題思路:

高數(shù)上的三重積分。注意:PI的精度要大些,一開始用的3.1415926通不過,精度太小,后來百度3.1415926535898。還有浮點(diǎn)數(shù)的除法記得*1.0。

題目中的oc = ob這條信息特別關(guān)鍵。

代碼:

#include <iostream> #include <cmath> #include <stdio.h> #include <iomanip> using namespace std; #define pi 3.1415926535898int main() {int t;cin>>t;int c=1;int a,b,h;while(t--){cin>>a>>b>>h;if(h>b){h=b;}double n1=pi*a*b*(h-h*h*h/(3.0*b*b)+b-(b*b*b)/(3.0*b*b));cout<<"Case "<<c++<<": "<<setiosflags(ios::fixed)<<setprecision(3)<<n1<<endl;}return 0; }


?

總結(jié)

以上是生活随笔為你收集整理的[2012山东ACM省赛] Fruit Ninja II (三重积分,椭球体积)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。