Saleh127

UVa 530

Jun 27th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. ll n,r,ans,f,i,j,k;
  10. while(cin>>n>>r && n||r)
  11. {
  12. if(n!=0 && r==0)
  13. {
  14. cout<<1<<endl;
  15. continue;
  16. }
  17. if(r>(n/2)) r=n-r;
  18. ans=1;
  19. for(i=0;i<r;i++)
  20. {
  21. ans=ans*(n-i);
  22. ans=ans/(i+1);
  23. }
  24. cout<<ans<<endl;
  25. }
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment