HDU 3398 string

Source: Internet
Author: User

No. The table cannot be typed, but only the rule is known.

  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  
 

Rule:

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 assigned ed 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

 

12 2 sample output

 

2

 

 

HDU 3398 string

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.