104562024-04-02 22:53:07111Fibonacci Sequencescpp17Time limit exceeded 50/1002.099s4976 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long

vector<int>f,v,F;

int solve(int x,int i,int c,int d){
	if(x==1){
		int ans=1;
		v.push_back(c);
		for(int i:v){
			ans*=F[d]/F[i]/F[d-i];
			d-=i;
		}
		v.pop_back();
		return ans;
	}
	int ans=0;
	for(int j=i;j<f.size();j++){
		if(x%f[j]){
			continue;
		}
		if(j==i){
			ans+=solve(x/f[j],j,c+1,d+1);
		}
		else{
			v.push_back(c);
			ans+=solve(x/f[j],j,1,d+1);
			v.pop_back();
		}
	}
	return ans;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	f.push_back(1);
	f.push_back(2);
	F.push_back(1);
	for(int i=0;i<42;i++){
		f.push_back(*--f.end()+*----f.end());
		F.push_back(F.back()*(i+1));
	}
	int T;
	cin>>T;
	while(T--){
		int M;
		cin>>M;
		cout<<solve(M,1,0,0)<<'\n';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1892 KiB
2Accepted4ms2116 KiB
subtask225/25
3Accepted3ms2344 KiB
4Accepted3ms2668 KiB
5Accepted3ms2640 KiB
6Accepted3ms2864 KiB
subtask325/25
7Accepted3ms3068 KiB
8Accepted4ms3176 KiB
9Accepted3ms3368 KiB
10Accepted3ms3584 KiB
subtask40/25
11Time limit exceeded2.099s3380 KiB
12Time limit exceeded2.069s4060 KiB
subtask50/25
13Time limit exceeded2.065s4456 KiB
14Time limit exceeded2.038s4976 KiB