Bobo has a triangle ABC with A(x1,y1),B(x2,y2)A(x1,y1),B(x2,y2) and C(x3,y3)C(x3,y3). Picking a point P uniformly in triangle ABC, he wants to know the expectation value E=max{SPAB,SPBC,SPCA}E=max{SPAB,SPBC,SPCA} where SXYZSXYZ denotes the area of triangle XYZ.
Print the value of 36×E36×E. It can be proved that it is always an integer.
Print the value of 36×E36×E. It can be proved that it is always an integer.
输入描述:
The input consists of several test cases and is terminated by end-of-file. Each test case contains six integers x1,y1,x2,y2,x3,y3x1,y1,x2,y2,x3,y3. * |x1|,|y1|,|x2|,|y2|,|x3|,|y3|≤108|x1|,|y1|,|x2|,|y2|,|x3|,|y3|≤108 * There are at most 105105 test cases.
输出描述:
For each test case, print an integer which denotes the result.
这题期望值为三角形面积的22/36,可以自己建模打随机数求(好吧太菜了只会这个);
至于正常的推导过程如下图:
然后就可以贴代码了(别忘了答案是期望的36倍哦):
#include<bits/stdc++.h>using namespace std;int n,m,k,t;long long a[10];intmain(){while(~scanf("%lld%lld%lld%lld%lld%lld",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6])){long long s=abs((a[1]*a[4]-a[3]*a[2])+(a[3]*a[6]-a[5]*a[4])+(a[5]*a[2]-a[1]*a[6]));printf("%lld\n",s*11);}}