#include<iostream>
#include <algorithm>
using namespace std;
int count=0,cache[50];
int f(int n)
{
if(n==2) count++;
if(n==0 || n==1) return n;
else if(cache[n]!=-1) return cache[n];
else cache[n]= f(n-1)+f(n-2);
return cache[n];
}
int main()
{
std::cout << f(5);
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgY291bnQ9MCxjYWNoZVs1MF07CgppbnQgZihpbnQgbikKeyAgCiAgICBpZihuPT0yKSBjb3VudCsrOwogICAgaWYobj09MCB8fCBuPT0xKSByZXR1cm4gbjsKICAgIGVsc2UgaWYoY2FjaGVbbl0hPS0xKSByZXR1cm4gY2FjaGVbbl07CiAgICBlbHNlIGNhY2hlW25dPSBmKG4tMSkrZihuLTIpOwogICAgcmV0dXJuIGNhY2hlW25dOyAKfQoKaW50IG1haW4oKQp7CiAgc3RkOjpjb3V0IDw8IGYoNSk7CiByZXR1cm4gMDsKfQ==
prog.cpp: In function ‘int f(int)’:
prog.cpp:9: error: reference to ‘count’ is ambiguous
prog.cpp:5: error: candidates are: int count
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:3987: error: template<class _IIter, class _Tp> typename std::iterator_traits::difference_type std::count(_IIter, _IIter, const _Tp&)
prog.cpp:9: error: reference to ‘count’ is ambiguous
prog.cpp:5: error: candidates are: int count
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:3987: error: template<class _IIter, class _Tp> typename std::iterator_traits::difference_type std::count(_IIter, _IIter, const _Tp&)