填寫問券˙抽7-11禮券來自星星的你也會打廣告?輕忽小中風,當心變殘障反服貿流血 法官要警交...
2012-04-12 20:05:43 人氣(387) | 回應(0) | 推薦(0) | 收藏(0) 上一篇 | 下一篇

[UVA][Math] 11909 - Soya Milk

0
收藏
0
推薦

On the dining table we have a packet of soya milk. We can look at the packet as a rectangular box with height h, length l and width w. We tilt it against a base edge, as shown in the picture. Soya milk then comes out through the opening in the top face. This process stops when the milk level is no longer higher than the opening.

Write a program that computes the volume of soya milk remaining in the packet.

Note that the problem description may not perfectly match the real-life situation, but to solve this problem you must follow our assumptions.

Input

Each input file contains multiple test cases, and each test case starts on a new line.

Each case consists of four positive integers l, w, h (in centimetres) and θ (in degrees), all strictly less than 90.

Output

For each test case, output a line containing the volume of soya milk inside the packet in millilitres, correct to 3 decimal places.

Sample Input

9 6 19 20

Sample Output

937.555 mL

 
#include <stdio.h>
#include <math.h>

int main() {
int l, w, h, theta;
while(scanf("%d %d %d %d", &l, &w, &h, &theta) == 4) {
double b = theta/360.0 * 2 * acos(-1);
if(l*tan(b) <= h)
printf("%.3lf mL\n", l*w*h - w*0.5*l*l*tan(b));
else
printf("%.3lf mL\n", w*0.5*h*h*1/tan(b));
}
return 0;
}


11909Soya Milk
台長:Morris
人氣(387) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][DP] 967 - Circular
此分類上一篇:[UVA][Math] 920 - Sunny Mountains

我要回應
是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入以下數字 (ex:123)

(有*為必填)
詳全文