HDU 3723 Delta Wave(默慈金数)
来源:互联网 发布:西科在线网络教育 编辑:程序博客网 时间:2024/05/16 15:03
传送门
Delta Wave
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1160 Accepted Submission(s): 370
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.
– 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 10100.
Sample Input
3
4
Sample Output
4
9
Source
2010 Asia Tianjin Regional Contest
题目大意:
在一个无限大的“网格”上,限定“每步只能向右移动一格(可以向右上、右下横向向右),并禁止移动到y=0以下的地方”,让你求以这种走法用n步从(0,0)移动至(n,0)的可能形成的路径的总数。
解题思路:
其实这个题目就是让我们求
还可以写为:
这个题目的数据范围比较大,所以采用
import java.io.*;import java.math.BigDecimal;import java.math.BigInteger;import java.util.Calendar;import java.util.HashSet;import java.util.Scanner;import java.util.Set;public class Main{ public static void main(String args[]){ BigInteger a[] = new BigInteger[100005]; final BigInteger MOD = BigInteger.valueOf(10).pow(100); a[1] = BigInteger.ONE; a[2] = BigInteger.valueOf(2); for(int i=3; i<10005; i++){ a[i] = ( a[i-1].multiply(BigInteger.valueOf(2*i+1)).add(a[i-2].multiply(BigInteger.valueOf(3*i-3))) ).divide(BigInteger.valueOf(i+2)); } Scanner in = new Scanner(System.in); int n; while(in.hasNextInt()){ n = in.nextInt(); System.out.println(a[n].mod(MOD)); } }}
0 0
- HDU 3723 Delta Wave(默慈金数)
- hdu 3723 Delta Wave
- HDU 3723 Delta Wave
- HDU 3723 Delta Wave
- hdu 3723 Delta Wave
- HDU 1030 ( Delta-wave )
- HDU 3723 Delta Wave(组合计数,卡特兰数)
- hdu 3723 Delta Wave(卡特兰数)
- hdu 3723 Delta Wave (catalan数+组合数学)
- HDU 3723 Delta Wave(2010 Asia Tianjin Regional Contest )
- Catalan数-hdu-3723-Delta Wave
- hdu 1030 Delta-wave(找规律)
- HDU 1030 Delta-wave(找规律)
- HDU 1030 Delta-wave
- HDU 1030 Delta-wave
- HDU 1030 Delta-wave
- HDU-1030-Delta-wave
- hdu 1030 Delta-wave
- 逻辑地址、线性地址、物理地址和虚拟地址理解
- Android studio 2.1.2安装步骤
- RxAndroid+RxLifecycle+MVP实现异步请求,ButterKnife更新ui
- error: expected declaration specifiers or '...' before错误
- Redhat6.7-64-系统虚拟机安装中的分区和虚拟机使用技巧
- HDU 3723 Delta Wave(默慈金数)
- 数据结构实验之栈一:进制转换
- JCS和Redis
- 极光推送
- GZIP压缩原理分析(14)——第五章 Deflate算法详解(五05) 预备知识(04) 前缀码、原始哈夫曼编码原理以及deflate所用哈夫曼编码的性质
- linphone-LinphoneProxyConfig.java文件分析
- 中序线索二叉树Java实现
- Java String、StringBuffer和StringBuilder
- mysql error