104602024-04-02 23:21:29111Fibonacci Sequencescpp17Accepted 100/100188ms19436 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long

vector<int>f,v,F;

map<int,int>m;

void solve(int x,int i,int c,int d){
	if(x>1000000000){
		return;
	}
	if(d){
		int ans=1;
		v.push_back(c);
		int dd=d;
		for(int j:v){
			int y=1,z=1;
			for(int k=1;k<=j;k++){
				y*=dd-k+1;
				y/=k;
			}
			ans*=y/z;
			dd-=j;
		}
		m[x]+=ans;
		v.pop_back();
	}
	for(int j=i;j<f.size();j++){
		if(j==i){
			solve(x*f[j],j,c+1,d+1);
		}
		else{
			v.push_back(c);
			solve(x*f[j],j,1,d+1);
			v.pop_back();
		}
	}
}

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));
	}
	solve(1,1,0,0);
	int T;
	cin>>T;
	while(T--){
		int M;
		cin>>M;
		cout<<m[M]<<'\n';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted119ms11604 KiB
2Accepted118ms12120 KiB
subtask225/25
3Accepted118ms12072 KiB
4Accepted118ms12528 KiB
5Accepted118ms12340 KiB
6Accepted119ms12584 KiB
subtask325/25
7Accepted118ms12696 KiB
8Accepted118ms12776 KiB
9Accepted118ms12664 KiB
10Accepted118ms12656 KiB
subtask425/25
11Accepted173ms18836 KiB
12Accepted173ms18808 KiB
subtask525/25
13Accepted188ms19260 KiB
14Accepted186ms19436 KiB