推公式,上面是题解AC代码 解题思路,先推出前五项,然后再找规律,把后项除于前项或者前项除于后项一定会发现规律的!
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
typedef long long ll;
ll dp[maxn];
int n,w,q;
const ll mod = 998244353;
void init()
{
dp[0] = 1;
for(int i = 1; i < maxn; ++i)
{
dp[i] = (2 * i * 1LL - 1* 1LL) % mod;
}
for(int i = 1; i < maxn; ++i)
{
dp[i] = dp[i] * dp[i - 1] % mod;
}
}
void couts()
{
for(int i = 0; i < 10; ++i)
printf("%lld\n",dp[i]);
}
int main()
{
init();
//couts();
scanf("%d%d",&w,&q);
while(q--)
{
scanf("%d",&n);
printf("%lld\n",dp[n] * w * 1LL % mod);
}
return 0;
}