Source Code
#include <iostream>
#include <math.h>
using namespace std;

int fib(int n)
{
    int a = 0, b = 1, c = 0;
    for (int i = 0; i < n; i++)
    {
        c = a + b;
        a = b;
        b = c;
    }
    return c;
}

int main()
{
    int t;
    cin >> t;
    while (t > 0)
    {
        int n;
        cin >> n;
        cout << fib(n) << endl;
        t--;
    }
}
Copy
Study Schedule Heromnxpw0
GNU G++17
2076 ms
1.7 MB
Time Limit Exceeded