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

int main()
{
    int t;
    cin >> t;
    int mod = 1000000007;
    long long int* m = new long long[1000000 + 2];
    m[1] = 1;
    m[2] = 2;
    for (int i = 3; i <= 1e6; i++) {
        m[i] = (m[i - 1] + m[i - 2]) % mod;
    }
    while (t > 0)
    {
        int n;
        cin >> n;
        cout << m[n] % mod << endl;
        t--;
    }
    delete[] m;
}
Copy
Study Schedule Heromnxpw0
GNU G++17
302 ms
9.9 MB
Accepted