1 条题解
-
1zhuyichen LV 6 MOD @ 2024-09-16 11:38:20
#include <bits/stdc++.h> using namespace std; #define int long long const int p = 1e9+7; int n,m; int qmul(int a,int b) { int res=0; while(b) { if(b&1)res=(res+a)%p; a=(a+a)%p; b>>=1; } return res; } signed main() { cin>>n>>m; // int sum=(1+m)*m/2*n+(1+n)*n/2*m; int sum1 = (m%2)?qmul(m,(1+m)/2):qmul(1+m,m/2); sum1 = qmul(sum1,n); int sum2 = (n%2)?qmul(n,(1+n)/2):qmul(1+n,n/2); sum2 = qmul(sum2,m); cout<<(sum1+sum2)%p;//<<" "<<sum%p; return 0; }
- 1