Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************
- * ب*سم الله الرحمن الرحيم
- * Harunur Rashid
- ********************************
- ************Template Starts Here***********/
- #include<bits/stdc++.h>
- #include <tr1/unordered_set>
- #include <tr1/unordered_map>
- using namespace std;
- using std::tr1::unordered_set;
- using std::tr1::unordered_map;
- #define endl "\n"
- #define eps 1e-9
- #define sf scanf
- #define xx first
- #define yy second
- #define pf printf
- #define ppb pop_back
- #define sqr(x) ((x)*(x))
- #define mp make_pair
- #define pb push_back
- #define pi acos(-1.0)
- #define mod 1000000007
- #define degree(a) 180.0*a/pi
- #define radiun(a) pi*a/180.0
- #define pr(a) cout<<a<<"\n"
- #define sz(x) ((int)x.size())
- #define all(a) a.begin(),a.end()
- #define mem(a,b) memset(a,b,sizeof(a))
- #define leadingzero(x) __builtin_clz(x)
- #define trailingzero(x) __builtin_ctz(x)
- #define countbit(x) __builtin_popcount(x)
- #define lcm(a,b) (abs(a)/gcd(a,b))*abs(b)
- typedef long long int LL;
- typedef unsigned long long int LLU;
- typedef vector<int> vi;
- typedef pair<int,int> pii;
- template<class T>
- T mod_f(T num)
- {
- if(num>=0) return num%mod;
- else return ((num%mod)+mod)%mod;
- }
- template<class T>
- T fast_pow(T b,T p)
- {
- if(p==0) return 1;
- if(p%2)
- {
- T x=mod_f(mod_f(b)*mod_f(fast_pow(b,p-1)));
- return x;
- }
- else
- {
- T x=mod_f(fast_pow(b,p/2));
- x=mod_f(mod_f(x)*mod_f(x));
- return x;
- }
- }
- template<class T>
- T gcd(T a,T b)
- {
- a=abs(a);
- b=abs(b);
- while(b)
- {
- T r=a%b;
- a=b;
- b=r;
- }
- return a;
- }
- template<class T>
- LL stoi(T str)
- {
- stringstream ss(str);
- LL N;
- ss>>N;
- return N;
- }
- template<class T>
- string itos(T N)
- {
- stringstream ss;
- ss<<N;
- string ret;
- ret=ss.str();
- return ret;
- }
- template<class T>
- ostream& operator<<(ostream& out,vector<T>v)
- {
- int sz=v.size()-1;
- for(int i=0; i<=sz; i++) out<<v[i]<<" ";
- return out;
- }
- template<class T>
- ostream& operator,(ostream& out,T a)
- {
- out<<a<<" ";
- return out;
- }
- /* int gcd , x , y
- void extendedEuclid(int A,int B)
- {
- if(B==0)
- {
- gcd=A;
- x=1;
- y=0;
- }
- else
- {
- extendedEuclid(B,A%B);
- int u=x;
- x=y;
- y=u-(A/B)*y;
- }
- }
- */
- //bool isEqual(double a,double b) { return fabs(a-b)<=eps; }
- //bool isLessThan(double a,double b) { return a+eps<b; }
- //bool isLessThanEqual(double a,double b) { return a<b+eps; }
- //bool isGreaterThan(double a,double b) { return a>b+eps; }
- //bool isGreaterThanEqual(double a,double b) { return a+eps>b; }
- //bool Palindrome(string s) { return equal(s.begin(), s.end(), s.rbegin()); }
- //int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
- //bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
- //bool isUpper(char c){return c>='A' && c<='Z';}
- //bool isLower(char c){return c>='a' && c<='z';}
- /*/ 4 direction ....
- int dx[]= {+0,+1,+0,-1};
- int dy[]= {+1,+0,-1,+0};
- // 8 direction ....
- int dx[]= {+0,+1,+1,+1,+0,-1,-1,-1};
- int dy[]= {+1,+1,+0,-1,-1,-1,+0,+1};
- // Knight direction...
- int dx[]= {+1,-1,+2,-2,+2,-2,+1,-1};
- int dy[]= {+2,+2,+1,+1,-1,-1,-2,-2};
- */
- /***********Template Ends Here***********/
- LL minimum(int m)
- {
- LL n=m;
- LL match=n*((n-1)/2);
- LL L=match/n;
- LL ex=match%n;
- LL ret=((n-ex)*(L*L)%mod)%mod;
- ++L;
- ret=(ret+ex*(L*L)%mod)%mod;
- return mod_f(ret);
- }
- LLU maximum(int m)
- {
- LLU n=m-1;
- LLU ret=n*(n+1)*(2*n+1)/6;
- return mod_f(ret);
- }
- int main()
- {
- //ios_base::sync_with_stdio(0);cin.tie(false);cout.tie(false);
- int T,n;
- cin>>T;
- while(T--)
- {
- cin>>n;
- cout<<minimum(n)<<" "<<maximum(n)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement