Project Euler #230: Fibonacci Words

  • + 0 comments

    What is wrong in this code? Not even working for smaller inputs:

        #include <bits/stdc++.h>
    
        using namespace std;
    
        typedef long long ll;
        #define fast_cin()                    \
            ios_base::sync_with_stdio(false); \
            cin.tie(NULL);                    \
            cout.tie(NULL)
    
        void solve()
        {
            string a,b,res;
            ll n = 0;
            cin >> a >> b >> n;
            while (res.length()<n){
                res= a+b;
                a=b;
                b=res;
            }
            cout<<res[n+1]<<endl;
    
        }
        int main()
        {
            fast_cin();
            ll t;
            cin >> t;
            for (int it = 1; it <= t; it++)
            {
                solve();
            }
            return 0;
        }