码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 3398 String

时间:2015-05-07 16:23:54      阅读:72      评论:0      收藏:0      [点我收藏+]

标签:

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

  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

 

 

hdu 3398 String

标签:

原文地址:http://www.cnblogs.com/zufezzt/p/4484852.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!