Tetrahedron

https://vjudge.net/contest/387654#problem/A

参考:https://blog.csdn.net/xiaotutuyahttp_/article/details/107822150

算数学期望,直角四面体的公式

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
//#define sort(a,n,int) sort(a,a+n,less())

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair pii;
typedef char ch;
typedef double db;

const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
const int N=1e5+10;
const int mod=1e9+7;

ll MOD = 998244353;
ll inv[6000005];
ll sum[6000005];

int main()
{
	inv[0] = 0;
   	inv[1] = 1;
   	int n = 0;
 	int T = 0;
 	cin >> T;
 	
    for(int i = 2;i < 6000005;i++)
	{
        inv[i] = (MOD - MOD/i) * inv[MOD%i] % MOD;
    }
    for(int i = 1;i < 6000005;i++)
	{
        sum[i] = sum[i-1] + inv[i] * inv[i] % MOD;
        sum[i] %= MOD;
    }
    for(int i = 1;i < 6000005;i++)
	{
        sum[i] = sum[i] * inv[i];
		sum[i] %= MOD;
    }
    while(T--)
	{
        cin >> n;
        ll res = 3 * sum[n] % MOD;
        cout << res << endl;
    }
    return 0;
}

  

你可能感兴趣的:(Tetrahedron)