Submission #424906

#TimeUsernameProblemLanguageResultExecution timeMemory
424906A_DFibonacci representations (CEOI18_fib)C++14
5 / 100
2206 ms175928 KiB
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second #define du long double using namespace std; const int N=40; int a[N]; int f[N]; map<ii,int> mp; int bc(int sum,int i) { if(sum<0)return 0; // cout<<sum<<" "<<i<<endl; if(mp.count({sum,i})){ return mp[{sum,i}]; } if(i==0){ return sum==0; } int ret=0; ret+=bc(sum-f[i],i-1); ret+=bc(sum,i-1); return mp[{sum,i}]=ret; } void solve() { int n; cin>>n; f[1]=1; f[2]=2; for(int i=3;i<=24;i++){ f[i]=f[i-1]+f[i-2]; } int sum=0; while(n--){ int a; cin>>a; sum+=f[a]; // mp.clear(); int ans=bc(sum,24); cout<<ans<<endl; } } main() { int t=1; //cin>>t; while(t--)solve(); }

Compilation message (stderr)

fib.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
#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...