Submission #424639

#TimeUsernameProblemLanguageResultExecution timeMemory
424639Rouge_HugoFibonacci representations (CEOI18_fib)C++14
5 / 100
4067 ms460 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back using namespace std; const int N=15009; int a[N],c[N],b[N]; vector<int>v; void go(int x,int sum) { if(x==v.size()) { if(sum>15000)return; b[sum]++; return; } go(x+1,sum); go(x+1,sum+v[x]); } int main() { a[1]=1;a[2]=2; v.pb(1);v.pb(2); for(int i=3;i<=20;i++) { a[i]=a[i-1]+a[i-2]; v.pb(a[i]); } go(0,0); int n;cin>>n;ll r=0; for(int i=0;i<n;i++)cin>>c[i]; for(int i=0;i<n;i++) { r+=a[c[i]]; if(r>15000)while(1)r++; cout<<b[r]<<endl; } }

Compilation message (stderr)

fib.cpp: In function 'void go(int, int)':
fib.cpp:12:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     if(x==v.size())
      |        ~^~~~~~~~~~
#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...