S5來襲4/11旗艦上市老王現身說法關鍵字魅力!法人:14檔今年本業虧定了買太多也不行!7500...
2012-05-06 10:18:14 人氣(353) | 回應(0) | 推薦(0) | 收藏(0) 上一篇 | 下一篇

[UVA][EASY][Math] 10432 - Polygon Inside A Circle

0
收藏
0
推薦

Brightness of Brain Contest
Problem D
Time limit: 1 second Memory: 16 MB

Polygon Inside A Circle

The Problem

Consider a polygon of equal sides inside a circle as shown in the figure below.

Figure: The regular polygon inside a circle

Given the radius of the circle and number of sides. You have to find the area of the polygon.

The Input

In each line there will be two numbers indicating the radius `r' (0<r<20000) and the number of sides of the polygon `n' (2<n<20000) respectively. Input is terminated by `EOF'.

The Output

Output the area in each line. The number must be rounded to the third digit after the decimal point.

Sample Input

2 2000
10 3000

Sample Output

12.566
314.159


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

int main() {
double r, n;
while(scanf("%lf %lf", &r, &n) == 2) {
printf("%.3lf\n", n*r*r*sin(2*acos(-1)/n)/2);
}
return 0;
}

10432Polygon Inside A Circle
台長:Morris
人氣(353) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][DP] 11151 - Longest Palindrome
此分類上一篇:[UVA][最大值最小化][貪婪+二分] 11413 - Fill the Containers

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

(有*為必填)
詳全文