E.cpp 296 B

1234567891011121314151617181920
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. LL cnr(int n,int r){
  5. if(r*2>n){
  6. r=n-r;
  7. }
  8. LL p=1LL;
  9. for(int i=0;i<r;i++)p*=(n-i);
  10. for(int i=2;i<=r;i++)p/=i;
  11. return p;
  12. }
  13. int main() {
  14. int m,n;
  15. while(cin>>m>>n){
  16. cout<<cnr(m,n)<<endl;
  17. }
  18. return 0;
  19. }