牛客多校2 - Keyboard Free(几何)

题目链接:点击查看

题目大意:给出三个同心圆,从三个同心圆上分别选择三个顶点组成一个非退化的三角形,求三角形面积的期望

题目分析:参考博客:http://www.koule2333.top:3000/s/HJn9liYyw

借图:

牛客多校2 - Keyboard Free(几何)_第1张图片

如图所示,在利用向量表示出三角形的面积后,会带有两个以角度为变量的参数,且积分时带有绝对值,因为题目对精度的要求不高,所以我们可以将角度做等分,因为时间给的充足,所以我做的是 500 等分

另外向量叉积的运算公式如下:

a\times b=(l,m,n)\times (o,p,q)=(mq-np,no-lq,lp-mo)

因为只是第三维都为零,所以答案就是lp-mo

代码:
 

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;

typedef long long LL;

typedef unsigned long long ull;

const int inf=0x3f3f3f3f;

const int N=500;

const double pi=acos(-1.0);

double r[4],_cos[N+100],_sin[N+100];

void init()
{
	double delt=2*pi/N,a=0;
	for(int i=0;i<=N;i++)
	{
		_cos[i]=cos(a);
		_sin[i]=sin(a);
		a+=delt;
	}
}

int main()
{
#ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
#endif
//	ios::sync_with_stdio(false);
	init();
	int w;
	cin>>w;
	while(w--)
	{
		for(int i=1;i<=3;i++)
			scanf("%lf",r+i);
		sort(r+1,r+4);
		double ans=0;
		for(int i=0;i

 

你可能感兴趣的:(几何)