This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
unsigned long long GetGCM(unsigned long long m, unsigned long long n)
{
unsigned long long q;
if(m==0 || n==0) return 0;
do{
q = m%n;
if(q){
m = n;
n = q;
}
}while(q);
return n;
}
const long long MOD = 1000000007;
unsigned long long aNum;
unsigned long long solve1(unsigned long long n) {
if (n == 1) return aNum;
unsigned long long ret = solve1(n >> 1);
return (((ret*ret) % MOD) * (n & 1LL ? aNum : 1LL)) % MOD;
}
unsigned long long solve(unsigned long long a, unsigned long long x) {
aNum = a % MOD;
return solve1(x);
}
int main()
{
unsigned long long H=0,W=0;
unsigned long long answer=0,gcm=0;
cin>>H>>W;
for(unsigned long long i=0; i<H; i++){
for(unsigned long long j=0; j<W; j++){
answer+=(i+1)*(j+1)*(W-j)*(H-i);
}
}
unsigned long long temp=H*(H+1)/2*W*(W+1)/2;
answer=answer*9;
gcm = GetGCM(answer,temp);
if(gcm!=0){
answer/=gcm;
temp/=gcm;
}
cout<<(answer*solve(temp,1000000005))%1000000007<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |