• Source
    1. #include<stdio.h>
    2. int main()
    3. {
    4. double N,M,a,b,c,d,i,j,l;
    5. while(scanf("%lf%lf",&N,&M)!=EOF)
    6. {
    7. if(N==0 && M==0)
    8. {
    9. break;
    10. }
    11. b=N-M;
    12. if(b>M)
    13. {
    14. a=1;
    15. c=1;
    16. for(i=b+1; i<=N; i++)
    17. {
    18. a*=i;
    19. }
    20. for(j=M;j>=1;j--)
    21. {
    22. c*=j;
    23. }
    24. d=a/c;
    25. printf("%.0lf things taken %.0lf at a time is %.0lf exactly.\n",N,M,d);
    26. }
    27. else
    28. {
    29. a=1;
    30. c=1;
    31. for(i=M+1; i<=N; i++)
    32. {
    33. a*=i;
    34. }
    35. for(j=b;j>=1;j--)
    36. {
    37. c*=j;
    38. }
    39. d=a/c;
    40. printf("%.0lf things taken %.0lf at a time is %.0lf exactly.\n",N,M,d);
    41. }
    42. }
    43. return 0;
    44. }