其他分享
首页 > 其他分享> > 杭电5 1007

杭电5 1007

作者:互联网

#include <bits/stdc++.h>

#include <algorithm>
#include <iostream>
#define ll long long
#define mem(a, b) memset(a, b, sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define rep(i, a, b) for (auto i = a; i <= b; ++i)
#define bep(i, a, b) for (auto i = a; i >= b; --i)
#define lowbit(x) x&(-x)
#define PII pair<int, int>
#define x first
#define y second
#define PLL pair<ll, ll>
#define PI acos(-1)
#define pb push_back
#define eb emplace_back
const double eps = 1e-6;
const int N = 2e5 + 10;
using namespace std;
int mod=1e9+7;
ll n,a,b,c;
ll qmi(ll m, ll k, ll p) {
    ll res = 1 % p, t = m;
    while (k) {
        if (k & 1) res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}

void solve() {
    cin >> n;
    ll key,a,b;
    n%=mod;
    a=n*(n+1)%mod*(2*n+1)%mod*qmi(6,mod-2,mod)%mod;
    b=n*(n+1)%mod*qmi(2,mod-2,mod)%mod;
    ll ans=a*b%mod;
    ll sk = (a - 1) * (b - 1) % mod + (b - 1) * (b - 1) % mod;
    cout<<(sk+ans)%mod<<endl<<ans*n%mod*n%mod<<endl;
}
int main() {
    ios::sync_with_stdio(0);
    int t = 1;
    cin >> t;
    while (t--)solve();
    return 0;
}

标签:int,res,ll,long,杭电,1007,define,mod
来源: https://blog.csdn.net/qq_45913169/article/details/119359540