Random Point in Triangle

题目链接

题意:多组输入三角形各个顶点坐标p1,p2,p3,在三角形中任取一点p,计算 期望E=max(S(p,p1,p2),max(S(p,p1,p3),S(p,p2,p3)));

思路:用随机数找规律,找到了篇大佬的博客https://blog.csdn.net/weixin_43350051/article/details/97139683,然后引用了其中的公式写的。写这题拓展了自己的思维。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
    ll x1,y1,x2,y2,x3,y3;
    while(~scanf("%lld%lld%lld%lld%lld%lld",&x1,&y1,&x2,&y2,&x3,&y3))
    {
        ll ans=(ll)(x2-x1)*(y3-y1)-(ll)(y2-y1)*(x3-x1);
        printf("%lld
",(ll)abs(ans)*11);
    }
}
原文地址:https://www.cnblogs.com/2462478392Lee/p/11285687.html