Untitled

 avatar
user_3459908
plain_text
a month ago
870 B
4
Indexable
Never
#include<bits/stdc++.h>
using namespace std;


int n,k;
int a[25];
vector<string> res;
long long fibo[93];

void sinhfb(){
	fibo[0] = 1;
	fibo[1] = 1;
	for(int i = 2; i <= 92; i++){
		fibo[i] = fibo[i-1] + fibo[i-2];
	}
}

void backtrack(int pos){
	if(pos > k){
		string s = "";
		for(int i = 1; i <= k; i++){
			s += to_string(a[i]) +" ";
		}
		res.push_back(s);
		return;
	}
	for(int i = pos; i <= n - k + pos; i++){
		if(a[pos - 1] < i){
			a[pos] = i;
			backtrack(pos+1);
		}
	}	
}


int main(){
	cin>>n>>k;
	sinhfb();
	for(int i = 0; i<= 92; i++){
		cout<<fibo[i]<<" ";
	}
	cout<<endl;
	backtrack(1);
	for(string s : res){
		cout<<s<<endl;
	}
	for(int i = 1; i <= 92; i++){
		if(fibo[i] < res.size()){
			cout<<fibo[i]<<": ";
			cout<<res[fibo[i] - 1]<<endl;
		}
		else{
			return 0;
		}
	}
	return 0;
}
 
Leave a Comment