CSU 1320 scoop water (catlan number)

Source: Internet
Author: User
1320: scoop watertime limit: 2 sec memory limit: 128 MB
Submit: 494 solved: 129
[Submit] [Status] [web board] Description

I just bought two water polo a and B today, and the capacity is 1 litre. He plans to use this water polo to play games.

First, the supervisor has prepared a water tank with an infinite capacity. At the beginning, the water tank is empty. Then, the water tank A is used to add water to the water tank, and the water tank B is used to scoop out the water tank, when using water tank B to scoop out the water, there must be at least 1 litre of water in the water tank. In this way, the water tank will remain empty after N times of water diversion A and N times of water diversion B.

Input

Input Multiple examples until the end of the file.

Each example contains only one n (0 <n <= 10000), indicating that you must use n times of a watermark and N times of B watermark.

Output

For each example, please output a number, indicating the total number of correct draft methods so that there will always be enough water in the water tank when B is used in the draft process.

(Because the number is large, the output answer model is 1000000007)

Sample Input
12
Sample output
12
Hint

 

Csu_cx

 

Source

CSU monthly 2013 Oct.

 

Catlan number's application on the order of output stacks

 1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 #include<stdlib.h> 5 #include<algorithm> 6 using namespace std; 7 const int mod=1000000007; 8 long long f[10005]; 9 int n;10 int main()11 {12     //freopen("in.txt","r",stdin);;13     f[0]=1;14     for(int i=1;i<=10000;i++)15         for(int j=0;j<i;j++)16             f[i]=((f[j]*f[i-1-j])%mod+f[i])%mod;17             18     while(scanf("%d",&n)!=EOF)19     {20         printf("%lld\n",f[n]);21     }22     return 0;23 }
View code

 

CSU 1320 scoop water (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.