hdu 3398 String

2018.04.05 update: 今天无意间重新翻开了博客发现了这个历史遗留问题,已经知道是卡特兰数了,但由于取模的数不是素数啊。。。好像还是不太会做。

-----------------

不会做。打表打不起来,只知道规律。

  1 2 3 4 5 6 7 8
1 1              
2 2 2            
3 3 5 5          
4 4 9 14 14        
5 5 14 28 42 42      
6 6 20 48 90 132 132    
7 7 27 75 165 297 429 429  
 

规律: 

a[i][1]=i;

a[i][i]=a[i][i-1];

a[i][j]=a[i-1][j]+a[i][j-1];

Problem Description
Recently, lxhgww received a task : to generate strings contain '0's and '1's only, in which '0' appears exactly m times, '1' appears exactly n times. Also, any prefix string of it must satisfy the situation that the number of 1's can not be smaller than the number of 0's . But he can't calculate the number of satisfied strings. Can you help him?
 
Input
T(T<=100) in the first line is the case number.
Each case contains two numbers n and m( 1 <= m <= n <= 1000000 ).
 
Output
Output the number of satisfied strings % 20100501.
 
Sample Input
1 2 2
Sample Output
2
原文地址:https://www.cnblogs.com/zufezzt/p/4484852.html