GYM 100488 Yet Another Goat in the Garden

题目链接

题意

迷之题面,没有看懂,所以没做出来….

Find what part of the garden could be absorbed by the black hole in the worst case.

这句话可以看出来,原来出题人是想要我们求百分比。

坑啊/(ㄒoㄒ)/~~

解决

  1. 余弦定理: cos A=(b²+c²-a²)/2bc
  2. 海伦公式: p=(a+b+c)/2,S=sqrt(q(q-a)(q-b)(q-c))
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int N = 101010;
const int MOD = 1e9 + 7;
const double PI=acos(-1.0);

int main()
{
    int a,b,c,r;
    scanf("%d%d%d%d",&a,&b,&c,&r);

    //cos sita
    double cos1=(b*b+a*a-c*c)/2.0/b/a;
    double cos2=(b*b+c*c-a*a)/2.0/b/c;
    double cos3=(a*a+c*c-b*b)/2.0/a/c;

    //sita
    double sita1=acos(cos1);
    double sita2=acos(cos2);
    double sita3=acos(cos3);
    //de(sita1/PI*180);
    //de(sita2/PI*180);
    //de(sita3/PI*180);

    //S sita
    double s1=r*r*((1.0/tan(sita1/2.0)-(PI-(double)sita1)/2.0));
    double s2=r*r*((1.0/tan(sita2/2.0)-(PI-(double)sita2)/2.0));
    double s3=r*r*((1.0/tan(sita3/2.0)-(PI-(double)sita3)/2.0));

    //S triangle
    double l=(a+b+c)/2.0;
    double ans=l*(l-a)*(l-b)*(l-c);
    ans=sqrt(ans);
    //de(ans);

    double s=s1+s2+s3;

    printf("%.12lf",1-s/ans);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值