推式子的终点
非常无聊地进一步化简了本题的式子。
首先,没有
然后,有一对
注意到,该式等于
这显然容易计算。
注意到此式的理由是,
这里,
的形式,这里
#include <iostream>
#include <fstream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <bitset>
#include <functional>
#include <numeric>
#include <stdio.h>
#include <random>
using namespace std;
#define fast_io ios::sync_with_stdio(false), cin.tie(nullptr)
constexpr int M = 1e9+7;
constexpr int K = 8e8+6;
array<long long,2> fib(int n) {
if (!n) return { 0LL, 1LL };
auto [f0, f1] = fib(n>>1);
if (n&1) return { (f0*f0+f1*f1)%M, (f1*(2*f0+f1))%M };
else return { ((2*f1+M-f0)*f0)%M, (f0*f0+f1*f1)%M };
}
int main() {
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif
fast_io;
int t; cin >> t;
for (; t; --t) {
int n; cin >> n;
auto [f0, f1] = fib(n);
printf("%lld\n", (((n-5LL+M)*(f0+f1)%M+((n+2)*f0)%M+5)*K)%M);
}
return 0;
}