Submit  All submissions  Best solutions  Back to list 
BINOMIAL  Binomial coefficient 
Wersja polska  English version 
For integers n and k (0<=k<=n<1001) determine (binomial coefficient).
Input
The first line of the standard input contains one integer t (t<1001) which is the number of test cases.
In each of the next t lines there are numbers n and k.
Output
For each test print .
Example
Input
3
0 0
7 3
1000 2
Output: 1
35
499500
Added by:  Piotr Kąkol 
Date:  20100506 
Time limit:  10s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: SCM qobi 
Resource:  Binomial coefficient 
hide comments
20130828 17:30:01 Mitch Schwartz
Input does not contain (n,k) such that C(n,k) is greater than 8*10^8. 

20100903 13:39:57 Piotr Fusik
http://rt.perl.org/rt3/Public/Bug/Display.html?id=77640 

20100815 15:43:26 Remo Gisi
Zoltan: One day, someone should fix Math::BigInts "bnok()"function... 

20100506 21:59:22 Zoltán Zámbori
Thank You! I print from "7 0" to "7 7", result: 8 7 21 35 35 21 1 1 I'm always in troubles if i must use big numbers in Perl ... Last edit: 20100506 22:26:07 

20100506 21:49:32 Piotr KÄ…kol
For k=0 You should print 1 and for "7 6"  7 (that was just an example). ;) Last edit: 20100506 21:50:37 

20100506 21:39:05 Zoltán Zámbori
I get a WA, but i think my code (3600663) is correct. Piotr, can You check it? 

20100506 19:50:13 Piotr KÄ…kol
Thank You for Your remark. :) I deleted all tests where n 

20100506 19:34:32 numerix
I don't understand my WA. For n>=k it is clear, for n<k it should be 0 or maybe 1  I tried both cases. Large numbers cannot be a problem with Python either. Last edit: 20100506 19:35:12 