Source Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define sp ' '
#define assert(x,a) if(x){cout << a << endl;return;}
#define sortv(x)sort(x.begin(),x.end())
#define revev(x)reverse(x.begin(),x.end())
ll ans1 = 0;
long long f[10000003];
inline void fast(){
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    }
vector<vector<int>>graph;

vector<bool>vis(100001,false);
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
inline void answer(int c){assert(c==0,"NO")cout << "YES" << endl;}
long long pow(long long a, long long b, long long MOD)
{
 long long x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
long long InverseEuler(long long n, long long MOD)
{
 return pow(n,MOD-2,MOD);
}

long long C(long long n, long long r, long long MOD)
{

 return (f[n]/((InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
void solve()
{
    ll n;cin >> n;
    ans1 = 1;
    if(n % 2 == 0)
    {
        ans1++;
        n--;
    }
    ll temp = n / 2;
    while(temp > 0)
    {
        temp--;
        n--;
        ans1+=C(n,2,1000000007);
    }
    cout << ans1  %1000000007 << endl;
}
int main()
{
    fast();

     f[0] = 1;
      for(int i = 1 ; i <= 10000002 ; i++)
		f[i] = (f[i-1]*i)%1000000007;
    ll t{ 1 };cin >> t;
  // cin.ignore();
    while (t--)
    {
        solve();
    }
}
Copy
Study Schedule iwjx
GNU G++17
2094 ms
78.6 MB
Time Limit Exceeded