hdu 3723 Delta Wave 从(0,0)到(n,0)每次向右(上,下)的种类数

本文探讨了一种名为“otaku”的新物种的脑波特性,其脑波可以用二维坐标系中的多边形线条来近似,从点(0,0)到(N,0),仅允许向右上、右下或直行,且不越过y=0轴。文章提供了计算不同N值时otaku脑波种类数量的方法,并附带了Java实现代码。

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

Problem Description
A delta wave is a high amplitude brain wave in humans with a frequency of 1 – 4 hertz which can be recorded with an electroencephalogram (EEG) and is usually associated with slow-wave sleep (SWS).
-- from Wikipedia

The researchers have discovered a new kind of species called "otaku", whose brain waves are rather strange. The delta wave of an otaku's brain can be approximated by a polygonal line in the 2D coordinate system. The line is a route from point (0, 0) to (N, 0), and it is allowed to move only to the right (up, down or straight) at every step. And during the whole moving, it is not allowed to dip below the y = 0 axis.

For example, there are the 9 kinds of delta waves for N = 4:





Given N, you are requested to find out how many kinds of different delta waves of otaku.
 

Input
There are no more than 20 test cases. There is only one line for each case, containing an integer N (2 < N <= 10000)

 

Output
Output one line for each test case. For the answer may be quite huge, you need only output the answer module 10 100.
 

Sample Input
  
  
3 4
 

Sample Output
  
  
4 9

//

n个位置,枚举i, 从n个位置中选2*i个位置放+1,-1.其他方0.

在给定i的情况下。有-

T[i] = C(n,2*i) * Cat[i]

种放法。Cat[i] 表示第i个catalan数


import java.util.*;
import java.math.*;
//f[i]=C(n,2*i)*h(i)  h卡特兰数 h[i]=h[i-1]*(4*i-2)/(i+1)
public class Main{
    public static void main(String[] args){
        BigInteger mod=BigInteger.valueOf(10).pow(100);
        int n;
        Scanner cin=new Scanner(System.in);
        while(cin.hasNext()){
            n=cin.nextInt();
            BigInteger ans=BigInteger.ONE;//i=0
            BigInteger cnt=BigInteger.ONE;
            for(int i=1;2*i<=n;i++){
                cnt=cnt.multiply(BigInteger.valueOf(4*i-2));
                cnt=cnt.divide(BigInteger.valueOf(i+1));
                cnt=cnt.multiply(BigInteger.valueOf((n-2*i+1)*(n-2*i+2)));
                cnt=cnt.divide(BigInteger.valueOf((2*i)*(2*i-1)));
                ans=ans.add(cnt);
                ans=ans.mod(mod);
            }
            System.out.println(ans);
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值