Last active
December 12, 2015 00:28
-
-
Save Abreto/4683883 to your computer and use it in GitHub Desktop.
编程啦-Problem-1204
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Bianchengla - Problem 1204. */ | |
#include <stdio.h> | |
long long int C[20][20] = { | |
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}, | |
{0,1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190}, | |
{0,0,1,4,10,20,35,56,84,120,165,220,286,364,455,560,680,816,969,1140}, | |
{0,0,0,1,5,15,35,70,126,210,330,495,715,1001,1365,1820,2380,3060,3876,4845}, | |
{0,0,0,0,1,6,21,56,126,252,462,792,1287,2002,3003,4368,6188,8568,11628,15504}, | |
{0,0,0,0,0,1,7,28,84,210,462,924,1716,3003,5005,8008,12376,18564,27132,38760}, | |
{0,0,0,0,0,0,1,8,36,120,330,792,1716,3432,6435,11440,19448,31824,50388,77520}, | |
{0,0,0,0,0,0,0,1,9,45,165,495,1287,3003,6435,12870,24310,43758,75582,125970}, | |
{0,0,0,0,0,0,0,0,1,10,55,220,715,2002,5005,11440,24310,48620,92378,167960}, | |
{0,0,0,0,0,0,0,0,0,1,11,66,286,1001,3003,8008,19448,43758,92378,184756}, | |
{0,0,0,0,0,0,0,0,0,0,1,12,78,364,1365,4368,12376,31824,75582,167960}, | |
{0,0,0,0,0,0,0,0,0,0,0,1,13,91,455,1820,6188,18564,50388,125970}, | |
{0,0,0,0,0,0,0,0,0,0,0,0,1,14,105,560,2380,8568,27132,77520}, | |
{0,0,0,0,0,0,0,0,0,0,0,0,0,1,15,120,680,3060,11628,38760}, | |
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,136,816,3876,15504}, | |
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,17,153,969,4845}, | |
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,18,171,1140}, | |
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,190}, | |
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20}, | |
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1} | |
}; | |
int main() | |
{ | |
int T = 0; | |
int N = 0, M = 0; | |
scanf("%d\n", &T); | |
while(T--) | |
{ | |
scanf("%d %d", &N, &M); | |
printf("%lld\n", C[N-1][M-1]); | |
} | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a array for the table. | |
from math import factorial | |
def C(n, m): | |
return ( factorial(m)/(factorial(m-n)*factorial(n)) ) | |
outstr = '{\n' | |
for N in range(1,21): | |
if N > 1: | |
outstr += ',\n' | |
outstr += '\t{' | |
for M in range(1,21): | |
if M > 1: | |
outstr += ',' | |
if( M < N ): | |
outstr += '0' | |
else: | |
outstr += str(C(N, M)) | |
outstr += '}' | |
outstr += '\n}' | |
print outstr | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment