自己太菜,数学基础太差,这场比赛做的很糟糕。本来想吐槽出题人怎么都出很数学的题,现在回过头来想还是因为自己太垃圾,竞赛就是要多了解点东西。
找$f(cos(x))=cos(nx)$中$x^m$的系数模998244353。
wolfram alpha查了这个函数无果,得到了一堆sinx和cosx以及一个复指数的方程,其实应该推个几项再用数列查询查查看的,然后就会知道是Chebyshev polynomials
查WIKI直接就有通项公式了。然后就比较简单的了。
连方程都看不出来就别想着推导公式了。据说chebyshev多项式是高考内容
/** @Date : 2017-09-16 18:50:44
* @FileName: F chebyshev.cpp
* @Platform: Windows
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version : $Id$
*/
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;
const LL mod = 998244353;
LL fpow(LL a, LL n)
{
LL res = 1;
while(n)
{
if(n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
LL fac[N];
LL inv[N];
void init()
{
fac[0] = fac[1] = 1;
inv[0] = inv[1] = 1;
for(int i = 2; i < N; i++)
{
fac[i] = fac[i - 1] * i % mod;
inv[i] = (mod - mod / i) * inv[mod % i] % mod;
}
for(int i = 2; i < N; i++)
(inv[i] *= inv[i - 1]) %= mod;
}
int main()
{
init();
LL n , m;
while(~scanf("%lld%lld", &n, &m))
{
if((n - m) % 2)
{
printf("0\n");
continue;
}
LL a = n * (((n-m)/2LL)%2?-1LL:1LL) * fpow(2LL, m) % mod * inv[m] % mod;
LL c = inv[2];
for(LL i = (n - m) / 2 + 1; i <= (n + m) / 2 - 1; i++)
c = (c * i) % mod;
a = a * c % mod;
while(a < 0)
a += mod;
printf("%lld\n", a);
}
return 0;
}