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)