10456 | 2024-04-02 22:53:07 | 111 | Fibonacci Sequences | cpp17 | Time limit exceeded 50/100 | 2.099s | 4976 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1892 KiB | ||||
2 | Accepted | 4ms | 2116 KiB | ||||
subtask2 | 25/25 | ||||||
3 | Accepted | 3ms | 2344 KiB | ||||
4 | Accepted | 3ms | 2668 KiB | ||||
5 | Accepted | 3ms | 2640 KiB | ||||
6 | Accepted | 3ms | 2864 KiB | ||||
subtask3 | 25/25 | ||||||
7 | Accepted | 3ms | 3068 KiB | ||||
8 | Accepted | 4ms | 3176 KiB | ||||
9 | Accepted | 3ms | 3368 KiB | ||||
10 | Accepted | 3ms | 3584 KiB | ||||
subtask4 | 0/25 | ||||||
11 | Time limit exceeded | 2.099s | 3380 KiB | ||||
12 | Time limit exceeded | 2.069s | 4060 KiB | ||||
subtask5 | 0/25 | ||||||
13 | Time limit exceeded | 2.065s | 4456 KiB | ||||
14 | Time limit exceeded | 2.038s | 4976 KiB |