I love cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 2805 Accepted Submission(s): 770
Each test case contains a single Integer n(0<=n<=1e18).
If n=0, output 0
又因为n的范围为0- 1e18
所以需要用到模板:a*b%p
ll mul(ll a,ll b,ll p){
ll ans=0;
while(b){
if(b&1) ans=(ans+a)%p;
a=a*2%p;
b>>=1;
}
return ans;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll mul(ll a,ll b){
ll ans=0;
while(b){
if(b&1) ans=(ans+a)%mod;
a=a*2%mod;
b>>=1;
}
return ans;
}
int main(){
int t,n;
cin>>t;
while(t--){
cin>>n;
if(n==0||n==1) cout<<"0"<<endl;//特判
else{
n--;
cout<<mul(n,n)%mod*mul(n+1,n+1)%mod*2%mod<<endl;
}
}
return 0;
}