SPOJ 78 Marbles 组合数学

时间:2021-08-26 03:01:29

相当于从n-1个位置里面找k-1个位置放隔板

 #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm> #define LL long long int using namespace std; int main()
{
double n, k;
int T;
scanf( "%d", &T );
while ( T-- )
{
scanf( "%lf%lf", &n, &k );
if ( n - k < k - ) k = n - k + 1.0;
double ans = 1.0;
for ( double i = ; i < k; ++i )
{
ans *= ( n - i ) / i;
}
printf( "%.0f\n", ans );
}
return ;
}