【推导】计蒜客17119 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 F. Trig Function
题意:给你n,m,让你求cos(nx)的展开式的(cos(x))^m项的系数。
更一般的式子是这样的:。
队友的代码:
#include<cstdio> #include<algorithm> #include<queue> #include<set> using namespace std; long long n,k,i,ans; long long mo=998244353; long long ni(long long a,long long b) { long long c; if (b==1) return a; c=ni(a*a%mo,b/2); if (b%2==1) c=c*a%mo; return c; } int main(){ //freopen("ac.in","r",stdin); while (scanf("%lld%lld",&n,&k)!=EOF) { if (n<k || (n+k)%2==1) { printf("0\n"); continue; } ans=n%mo;// for (i=n-k+2;i<=n+k-2;i+=2) ans=ans*i%mo; for (i=2;i<=k;i++) ans=ans*ni(i,mo-2)%mo; if (k==0) ans=ans*ni(n%mo,mo-2)%mo; if ((n-k)/2%2==1) ans=mo-ans; printf("%lld\n",ans); } }
——The Solution By AutSky_JadeK From UESTC
转载请注明出处:http://www.cnblogs.com/autsky-jadek/