lightoj1067

maksyuki 发表于 oj 分类,标签:
0

1067 - Combinations

For example, say there are 4 items; you want to take 2 of them. So, you can do it 6 ways.Given n different objects, you want to take k of them. How many ways to can do it?

Input

Input starts with an integer T (≤ 2000), denoting the number of test cases.

Each test case contains two integers n (1 ≤ n ≤ 106), k (0 ≤ k ≤ n).

Output

For each case, output the case number and the desired value. Since the result can be very large, you have to print the result modulo 1000003.

Sample Input

Output for Sample Input

34 25 06 4 Case 1: 6Case 2: 1Case 3: 15

 

题目类型:组合数取模(Lucas)

算法分析:由于模值p不算太大且为质数,则可以使用Lucas定理求解