fork download
  1. #include<bits/stdc++.h>
  2. #define all(x) x.begin(), x.end()
  3. #define pb(x) push_back(x)
  4. #define MAXN 100005
  5. #define cout2(x, y) cout << x << " " << y << endl;
  6.  
  7. #define MOD 1000000007
  8. using namespace std;
  9.  
  10. int main(){
  11.  
  12. long long a, b;
  13. while(cin>>a>>b){
  14.  
  15.  
  16. long long ans = 0, aux;
  17.  
  18. for(int r = 1; r < b; r++){
  19.  
  20. aux = (a * (a + 1)/2)%MOD;
  21. aux = (aux * b)%MOD;
  22.  
  23. aux = ((aux + a )* r)%MOD;
  24. ans = (ans + aux)%MOD;
  25.  
  26. }
  27.  
  28. cout << ans << endl;
  29. }
  30.  
  31. }
Success #stdin #stdout 0s 3300KB
stdin
2 2
stdout
8