HDU6814:Tetrahedron——题解

http://acm.hdu.edu.cn/showproblem.php?pid=6814

emm……看题给出的那张图应该就能看懂题意了吧……

https://wenku.baidu.com/view/b58ffe8132d4b14e852458fb770bf78a65293a0b.html

网络的力量是真的强大(

#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const ll p=998244353;
const int N=6e6+5;
inline int read(){
    int X=0,w=0;char ch=0;
    while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
    while(isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
ll inv[N],E[N];
int main(){
    inv[1]=1;
    for(int i=2;i<N;i++){
        inv[i]=(ll)(p-p/i)*inv[p%i]%p;
    }
    for(int i=1;i<N;i++){
        E[i]=E[i-1]+inv[i]*inv[i]%p;
        E[i]%=p;
    }
    for(int i=1;i<N;i++){
        E[i]=(E[i]*inv[i])%p;
    }
    int T=read();
    while(T--){
        int n=read();
        printf("%lld\n",(ll)3*E[n]%p);
    }
    return 0;
}

+++++++++++++++++++++++++++++++++++++++++++

 +本文作者:luyouqi233。               +

 +欢迎访问我的博客:http://www.cnblogs.com/luyouqi233/+

+++++++++++++++++++++++++++++++++++++++++++

posted @ 2020-08-04 18:06  luyouqi233  阅读(200)  评论(0编辑  收藏