Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef vector<int> vi;
- #define rapid_io() ios::sync_with_stdio(false);cin.tie(0);
- #define endl '\n'
- #define pb push_back
- #define all(a) (a).begin(),(a).end()
- #define rall(a) (a).rbegin(),(a).rend()
- int main()
- {
- rapid_io();
- int n,m;
- while(cin>>n>>m)
- {
- if(n==0 && m==0)
- return 0;
- int arr1[n+1],arr2[m+1];
- for(int i=n-m+1;i<=n;i++)
- {
- arr1[i]=i;
- }
- for(int i=1;i<=m;i++)
- {
- arr2[i]=i;
- }
- for(int i=1;i<=m;i++)
- {
- for(int j=n-m+1;j<=n;j++)
- {
- if(arr1[j]%arr2[i]==0)
- {
- arr1[j]=arr1[j]/arr2[i];
- arr2[i]=1;
- }
- }
- }
- ll ans=1,lob=1,hor=1;
- for(int i=n-m+1;i<=n;i++)
- {
- lob*=arr1[i];
- }
- for(int i=1;i<=m;i++)
- {
- hor*=arr2[i];
- }
- ans=lob/hor;
- cout<<n<<" things taken "<<m<<" at a time is "<<ans<<" exactly."<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement