Ultraviolet-1478 delta wave (large number + catlan number)

Source: Internet
Author: User

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) (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 wavesN= 4:

GivenN, 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 integerN(2 <N10000)

Output

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

Sample Input

3 4

Sample output

4 9. From the coordinate (0, 0) to the line (n, 0), the line is extended by a unit of length to the right, and the height is either unchanged or + 1, either-1, n is known, and the idea of finding such a broken line is: we know that the number of increases and decreases is the same, and this is like the order of the catlan number's inbound and outbound stacks, so we select two K out-of-class Stack simulation times from N, then ans [k] = C [N] [2 K] * C [2 K] [k]/(k + 1 ), then we can remove the two delivery results is ans [k] = ans [k-1] * (n-2 * k + 2) * (n-2 * k + 1) /(K * (k + 1 ))
import java.io.*;import java.util.*;import java.math.*;public class Main{public static void main(String args[]){Scanner cin = new Scanner(System.in);BigInteger mod = BigInteger.ONE;for (int i = 1; i <= 100; i++)mod = mod.multiply(BigInteger.valueOf(10));while (cin.hasNext()) {int n = cin.nextInt();if (n == 0)break;BigInteger it = BigInteger.ONE;BigInteger ans = BigInteger.ONE;for (int i = 0; i < n/2; i++) {it = it.multiply(BigInteger.valueOf((n-2*i)*(n-2*i-1)));it = it.divide(BigInteger.valueOf((i+1)*(i+2)));ans = ans.add(it);}System.out.println(ans.mod(mod));}}}


Ultraviolet-1478 delta wave (large number + catlan number)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.