初次接触组合数学,比赛做到了卡特兰数,看了看大牛的博客,算是初步了解了一下
dalao博客:http://www.cppblog.com/MiYu/archive/2010/08/07/122573.html
链接:http://acm.hdu.edu.cn/showproblem.php?pid=3723
Delta Wave
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1269 Accepted Submission(s): 413
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:
![](https://i-blog.csdnimg.cn/blog_migrate/e83af7a43bc0fc38c115a37fa757db58.jpeg)
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, 0) 的种类。
思路 : 看题解都是浮云,小帅给我一讲就明白了,感谢小帅同学,贴上小帅同学的博客:
http://www.cnblogs.com/rhythmic/p/5472575.html
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
BigInteger mod = BigInteger.TEN.pow(100);
BigInteger sum = new BigInteger("0");
BigInteger t = new BigInteger("0");
while (read.hasNext()) {
int n = read.nextInt();
sum = BigInteger.ONE;
t = BigInteger.ONE;
for(int k = 1; k + k <= n; k++) {
t = t.multiply(BigInteger.valueOf((n-2*k+1)*(n-2*k+2))) .divide(BigInteger.valueOf(k*(k+1)));
System.out.println(t);
sum = sum.add(t);
}
System.out.println(sum.mod(mod));
}
}
}