Submission #72646

#TimeUsernameProblemLanguageResultExecution timeMemory
72646istleminFibonacci representations (CEOI18_fib)C++14
5 / 100
4097 ms704 KiB
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i<int(b);++i) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define trav(a,c) for(auto a: c) typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; const ll mod = 1e9+7; ll n; vi a; vi F; ll solve(ll k){ /*map<ll,ll> m; rep(i,0,k){ m[a[i]]++; } for(auto it = m.begin(); it!=m.end();it++){ if(it->second>1&&it!=m.begin()&&prev(it)->second==1){ } if(it->second>1) return 0; }*/ ll p = 0; rep(i,0,k) p += F[a[i]]; ll ans = 0; rep(mask,0,(1<<20)){ ll sum = 0; rep(i,0,20){ if((1<<i)&mask){ sum+=F[i+1]; } } ans+=(sum==p); } return ans; } int main(){ cin.sync_with_stdio(false); ll n; cin>>n; a.resize(n); rep(i,0,n){ cin>>a[i]; } F.resize(25); F[1] = 1; F[2] = 2; rep(i,3,25) F[i] = F[i-2]+F[i-1]; rep(i,0,n) cout<<solve(i+1)<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...