题意:
思路:手算了几项,然后把n为6的那一行输到OEIS,就搜到了切比雪夫多项式。
然后百度第一类切比雪夫多项式是这个公式:
注意"!!"不是阶乘的阶乘,而是不超过n且与n具有相同奇偶性的所有正整数连乘积。
n分类讨论下,当n为偶数时m=2*k, n为奇数时m=2*k-1
还有注意下"!!"的约分,可能下面的比上面的大
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 998244353;
ll fac[maxn] = {1};
ll n, m;
void init()
{
for(int i = 1; i < maxn; i++)
fac[i] = fac[i-1]*i%mod;
}
ll qmod(ll x, int q)
{
ll res = 1;
while(q)
{
if(q%2) res = res*x%mod;
x = x*x%mod;
q /= 2;
}
return res;
}
int main(void)
{
init();
while(~scanf("%lld%lld", &n, &m))
{
if(m > n) puts("0");
else if(n%2 && m%2 == 0) puts("0");
else if(n%2 == 0 && m%2) puts("0");
else
{
ll fz = n%mod;
if(m >= 1)
{
for(int i = n-m+1; i <= n+m-1; i++)
{
if(i%2 == (n+m-2)%2)
{
fz = fz*i%mod;
}
}
ll tmp = fz*qmod(fac[m], mod-2)%mod;
if((n-m)/2%2) tmp = -tmp;
printf("%lld\n", (tmp+mod)%mod);
}
else
{
ll t = 1;
for(int i = n+m-1; i <= n-m; i++)
{
if(i%2 == (n+m-2)%2)
t = t*i%mod;
}
ll tmp = fz*qmod(fac[m], mod-2)%mod*qmod(t, mod-2)%mod;
if((n-m)/2%2) tmp = -tmp;
printf("%lld\n", (tmp+mod)%mod);
}
}
}
return 0;
}