Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int mas[40];
- long long C(int n,int k)
- {
- if ((n==k) || (k==0)) {
- return 1;
- }
- if (k==1) {
- return n;
- }
- return C(n-1,k)+C(n-1,k-1);
- }
- int main()
- {
- ifstream cin;
- ofstream cout;
- cin.open("comb.in");
- cout.open("comb.out");
- long long n,k,p,c,t,last=0;
- cin >> n >> k >> p;
- for (int i=1; i<=k; i++) {
- c=C(n-i,k-i);
- t=0;
- while (p>=c) {
- t++;
- p-=c;
- c=C(n-t-i,k-i);
- }
- cout << t+1+last << ' ';
- last+=t+1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement