Submission #20007

#TimeUsernameProblemLanguageResultExecution timeMemory
20007algoshipda창문 (kriii4_C)C++14
3 / 100
0 ms1720 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lld; const lld MOD = 1e9 + 7; inline void mult(lld& a, lld b) { a%=MOD; b%=MOD; a = 1ll * a * b % MOD; } inline lld mult2(lld a, lld b) { a%=MOD; b%=MOD; return 1ll * a * b % MOD; } pair<lld, lld> extgcd(lld a, lld b) { if(b == 0) return {1,0}; pair<lld, lld> t = extgcd(b, a%b); return {t.second, t.first - t.second*(a/b)}; } lld inv(lld a) { return (extgcd(a, MOD).first % MOD + MOD ) % MOD; } int main() { lld h, w; scanf("%lld%lld",&h,&w); h %= MOD; w %= MOD; lld b = mult2(mult2(mult2(h,(h+1)%MOD), mult2(w,(w+1)%MOD)), inv(4)); lld hh = h; mult(hh, (h+1)%MOD); mult(hh, (h+2)%MOD); mult(hh, inv(6)); lld ww = w; mult(ww, (w+1)%MOD); mult(ww, (w+2)%MOD); mult(ww, inv(6)); lld a = mult2(hh,ww); mult(a, 9); printf("%lld",mult2(a, inv(b))); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...