BCDIV - Chia nhóm

Tác giả: skyvn97

Ngôn ngữ: C++

#include<stdio.h>
#define MAX   30
typedef unsigned long long ull;
int k,n,i,j;
ull t,ct;
ull opt[MAX][MAX];
void init(void)
{
     for (i=1;i<=MAX;i=i+1)
         for (j=1;j<=MAX;j=j+1)
             {
              if (i>j) opt[i][j]=0;
              if (i==j) opt[i][j]=1;
              if (i<j) opt[i][j]=opt[i-1][j-1]+i*opt[i][j-1];
             }
}
int main(void)
{    
    init();
    scanf("%llu",&t);
    for (ct=1;ct<=t;ct++)
        {
           scanf("%d",&n);
           scanf("%d",&k);
           printf("%llu",opt[k][n]);
           if (ct<t) printf("\n");              
        }    
}

Download