2019牛客暑期多校1F题

登录—专业IT笔试面试备考平台_牛客网

https://ac.nowcoder.com/acm/contest/881/F

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.

输入描述:

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);
    }
}

全部评论
证明有点错误三角形ABC的面积应该是6hl  期望算到应该是11/18
点赞 回复 分享
发布于 2019-07-20 12:48
纠正:算出来期望是11/18,但不影响代码和思路的正确性,请大家见谅😋 然后就是怎么看别人牛客博客啊,链接我应该只给小仙女发过来着emmm
点赞 回复 分享
发布于 2019-07-22 09:16
在三角形ADF内任取一点P,它与底边DF围成的面积的期望为什么是1/3ADF的面积
点赞 回复 分享
发布于 2019-07-20 16:08

相关推荐

淬月星辉:专利是什么?至少描述一下吧,然后把什么计算机二级、普通话这种拉低格调的证书删掉,不然hr以为你没东西写
点赞 评论 收藏
分享
评论
5
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务