2020 Multi-University Training Contest 5---- HDU--6814、Tetrahedron (数学,推式子)

题目链接

题面:
在这里插入图片描述

题意:
有一个四面体,已知某一个顶点上的三条边相互垂直,同时知道这三条边长度在 1 1 1 n n n 的正整数中均匀分布,且相互独立,令这个点到对应底面的距离为 h h h,求 1 h 2 \frac{1}{h^2} h21 的期望。

题解:
可以以该点为原点,三条边为轴,建立直角坐标系。
那么显然可以得到四面体所有点的坐标。
用叉积算出底面面积,运用体积公式列方程求解即可。

V = 1 6 a b c = 1 3 S h V=\dfrac{1}{6}abc=\dfrac{1}{3}Sh V=61abc=31Sh

可解得:

1 h 2 = 1 a 2 + 1 b 2 + 1 c 2 \dfrac{1}{h^2}=\dfrac{1}{a^2}+\dfrac{1}{b^2}+\dfrac{1}{c^2} h21=a21+b21+c21

那么:

E ( 1 h 2 ) = 3 ∗ E ( 1 a 2 ) E(\dfrac{1}{h^2})=3*E(\dfrac{1}{a^2}) E(h21)=3E(a21)

处理一个 1 a 2 \dfrac{1}{a^2} a21 的前缀和即可。

代码:

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<bitset>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<ctime>
#define ui unsigned int
#define ll long long
#define llu unsigned ll
#define ld long double
#define pr make_pair
#define pb push_back
//#define lc (cnt<<1)
//#define rc (cnt<<1|1)
#define len(x)  (t[(x)].r-t[(x)].l+1)
#define tmid ((l+r)>>1)
#define fhead(x) for(int i=head[(x)];i;i=nt[i])
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
using namespace std;

const int inf=0x3f3f3f3f;
const ll lnf=0x3f3f3f3f3f3f3f3f;
const double dnf=1e18;
const double alpha=0.75;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1.0);
const int hp=13331;
const int maxn=6000100;
const int maxm=100100;
const int maxp=100100;
const int up=1100;

ll inv[maxn],sum[maxn];

int main(void)
{
    inv[1]=1;
    sum[1]=3*inv[1]*inv[1];
    for(int i=2;i<maxn;i++)
    {
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
        sum[i]=(sum[i-1]+3*inv[i]*inv[i])%mod;
    }
    int tt,n;
    scanf("%d",&tt);
    while(tt--)
    {
        scanf("%d",&n);
        printf("%lld\n",sum[n]*inv[n]%mod);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值