zoj 1090 The Circumference of the Circle(海伦公式+正弦定理)

29 篇文章 0 订阅
7 篇文章 0 订阅

【题目大意】:给出三角形三个点,求外接圆周长。


【解题思路】:

由正弦定理,a/sinA=b/sinB=c/sinC=2R,得sinA=a/(2R),又三角形面积公式S=(bcsinA)/2,所以S=(abc)/(4R),故R=(abc)/(4S).

然后面积S由海伦公式来求。

之后没了....


【代码】:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
#include <cctype>
#include <map>
#include <iomanip>
                   
using namespace std;
                   
#define eps 1e-8
#define pi acos(-1.0)
#define inf 1<<30
#define linf 1LL<<60
#define pb push_back
#define lc(x) (x << 1)
#define rc(x) (x << 1 | 1)
#define lowbit(x) (x & (-x))
#define ll long long

double x1,yy1,x2,y2,x3,y3,a,b,c,stmp,r,p,s;

inline double get_dis(double x,double x2,double y,double y2){
    return sqrt((x-x2)*(x-x2)+(y-y2)*(y-y2));    
}

int main(){
    while (~scanf("%lf%lf%lf%lf%lf%lf",&x1,&yy1,&x2,&y2,&x3,&y3)){
        a=get_dis(x1,x2,yy1,y2);
        b=get_dis(x1,x3,yy1,y3);
        c=get_dis(x2,x3,y2,y3);
        p=(a+b+c)/2.0;
        stmp=sqrt(p*(p-a)*(p-b)*(p-c));
        r=a*b*c/4.0/stmp;
        s=2*pi*r;
        printf("%.2f\n",s);
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值