GYM 100488 Yet Another Goat in the Garden

来源:互联网 发布:免费行业报告下载知乎 编辑:程序博客网 时间:2024/05/22 00:14

题目链接

题意

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

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 0x3f3f3f3fvoid 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);}
原创粉丝点击