2017 ACM-ICPC 西安网络赛 F.Trig Function Chebyshev多项式

本文介绍了一个关于寻找$f(cos(x))=cos(nx)$中$x^m$的系数模998244353的问题,并通过使用Chebyshev多项式的通项公式给出了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自己太菜,数学基础太差,这场比赛做的很糟糕。本来想吐槽出题人怎么都出很数学的题,现在回过头来想还是因为自己太垃圾,竞赛就是要多了解点东西

找$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;
}

转载于:https://www.cnblogs.com/Yumesenya/p/7532979.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值