如題
#include <stdio.h>
int main( void )
{
int m, n;
while( 1 )
{
unsigned long long int a, b;
unsigned long long int ans = 1;
scanf( "%llu%llu", &n, &m );
a = n;
b = m;
if( n - m < m )
m = n - m;
if( n == 0 && m == 0 )
break;
else if( m == 1 )
printf( "%llu things taken %llu at a time is %llu exactly.\n", a, b, a );
else if( m == 0 )
printf( "%llu things taken %llu at a time is 1 exactly.\n", a, b );
else
{
int i, j = 2;
for( i = n-m+1; i <= n; i++ )
{
ans *= i;
while( ans % m == 0 )
{
ans /= m;
m--;
}
while( ( j <= m ) && ( ans % j == 0 ) )
{
ans /= j;
j++;
}
}
}
printf( "%llu things taken %llu at a time is %llu exactly.\n", a, b, ans );
}
return 0;
}