题解 | #牛牛的Hermite多项式#

牛牛的Hermite多项式

https://www.nowcoder.com/practice/0c58f8e5673a406cb0e2f5ccf2c671d4

#include<bits/stdc++.h>
using namespace std;
int Hermite(int n,int x)
{
    if(n==0)
    {
        return 1;
    }
    if(n==1)
    {
        return 2*n;
    }
    return 2*x*Hermite(n-1,x)-2*(n-1)*Hermite(n-2,x);
}
int main()
{
    int n=0,x=0;
    cin>>n>>x;
    if(n<0)
    {
        return 0;
    }
    cout<<Hermite(n,x);
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务