hdu 6814 Tetrahedron
生活随笔
收集整理的這篇文章主要介紹了
hdu 6814 Tetrahedron
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目
題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=6814
思路
在四面體
中
由
可推出
那么E(x)=p*(1/a^2 + 1/b^2 + 1/c^2)(a、b、c屬于1~n)
E(x)=1/n*(1/a^2)*3(a從1~n)
代碼
#include<bits/stdc++.h> #define int long long using namespace std; const int mod=998244353; int inv[6000100],ans[6000010]; void getinv(int n){ans[1]=1;inv[1]=1;for(int i=2;i<n;i++){inv[i]=(mod-mod/i)*inv[mod%i]%mod;ans[i]=(ans[i-1]+inv[i]*inv[i]%mod)%mod;} } signed main(){ // ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int t;scanf("%lld",&t);getinv(6000010);while(t--){int n;scanf("%lld",&n);printf("%lld\n",3*ans[n]*inv[n]%mod);}return 0; }總結
以上是生活随笔為你收集整理的hdu 6814 Tetrahedron的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: RT6863D/TR(6863D)
- 下一篇: 一场大梦-深造梦