[数学]hdu-6550-Circle

http://acm.hdu.edu.cn/showproblem.php?pid=6550

这是一道好简单的数学题。。。要求保留6位小数。。。我pi写了8位精度还是炸了。。。我也不知道为啥。。。因为这了Wa了3发。。。

正多边形面积公式 n*r^2*sin(2pi/n) r是半径
这个题要求加一个点 根据三角形面积公式 要加在终点 而正好与一个内部的三角形构成一个对角线垂直的四边形

如图所示 因此面积公式为
(n-1)*r^2*sin(2pi/n)+r*r*sin(pi/n)

#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<ctime>
#include<stack>
#include<map>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
const double PI = 3.141592653589793238;
int main() {
	int n;
	while (cin >> n) {
		//cout << (n - 1) * sin((2 * PI) / n)/2<< endl;
		double ans = (n - 1)* sin(2 * PI/n)/2 + sin(PI / n);
		printf("%.6f\n", ans);
	}
	return 0;
}
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇