24h購物| | PChome| 登入
2012-05-06 10:18:14| 人氣1,522| 回應0 | 上一篇 | 下一篇

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

推薦 0 收藏 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;
}

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

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文