fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define max3(a,b,c) max(max(a,b),c)
  4. #define min3(a,b,c) min(min(a,b),c)
  5. #define PI acos(-1.0)
  6. #define LL long long
  7. #define INF_MAX 2147483647
  8. #define INF_MIN -2147483647
  9. #define MX 1000005
  10. #define MOD 1000000007
  11. int main()
  12. {
  13. //freopen("a.in", "r", stdin);
  14. //freopen("a.out", "w", stdout);
  15. LL n,r,temp1,temp2,res;
  16. while(scanf("%lld%lld",&n,&r))
  17. {
  18. if(n==0 && r==0) break;
  19. temp1=n;
  20. temp2=r;
  21. if(n-r<r) r=n-r;
  22. res=1;
  23. for(int i=1;i<=r;i++)
  24. {
  25. res=res*n;
  26. res=res/i;
  27. n--;
  28. }
  29. printf("%lld things taken %lld at a time is %lld exactly.\n",temp1,temp2,res);
  30. }
  31. }
  32.  
Success #stdin #stdout 0s 3416KB
stdin
100  6
      20  5
      18  6
       0  0
stdout
100 things taken 6 at a time is 1192052400 exactly.
20 things taken 5 at a time is 15504 exactly.
18 things taken 6 at a time is 18564 exactly.