Banzhuan
思维
最小代价就是先在底层铺一遍,然后再铺xOz,yOz两个平面,由于底层已经有了,所以在z轴上,两个平面都是从2开始加(其实最后减1就可以了),然后我们发现z轴除了底层放一个,上边是不用放的,都加起来就可以了
#include <bits/stdc++.h>
#define ll long long
#define mul(a,b) (1ll*(a)*(b))%mod
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 9;
ll q_pow(ll a, ll n)
{
ll ans = 1;
while(n)
{
if(n & 1) ans = (ans * a) % mod;
a = (a * a) % mod;
n >>= 1;
}
return ans % mod;
}
ll inv(ll a)
{
return q_pow(a, mod - 2) % mod;
}
int main()
{
int TT;cin>>TT;while(TT--)
{
ll n;
cin >> n;
n %= mod;
ll x1 = mul(n,inv(2)), x2 = mul(n,n+1), x3 = mul(2*n+1, inv(6));
ll mx = mul(mul(x1,x2)%mod,mul(x2,x3));
ll mi = mul(mul(inv(2),x2), mul(x2,x3)) % mod;
ll xx = mul(mul(n,n+1),inv(2));
mi = (mi + (xx - 1) * (xx - 1) % mod ) % mod;
ll t = mul(mul(mul(n,n+1),2*n+1),inv(6)) % mod;
mi = (mi + (t - 1) * (xx - 1) % mod ) % mod;
printf("%lld\n%lld\n",mi, (mx * n) % mod);
}
return 0;
}