0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-19 22:25:27 +00:00

48570 【LGR-089】洛谷 8 月月赛 II

T166874: R55803919
This commit is contained in:
Baoshuo Ren 2021-08-13 18:38:30 +08:00 committed by Baoshuo Ren
parent 2fa8305968
commit ffffd5fcd1
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,17 @@
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long t, n, k, k1, k2;
int main() {
cin >> t;
while (t--) {
cin >> n >> k;
k1 = k + 1 >> 1;
k2 = k >> 1;
cout << 1ll * (((((n * (n + 1)) / 2 % mod * k1 % mod) - (((k1 - 1) * k1) / 2 % mod) % mod) + ((((n - 1) * n) / 2 % mod * k2 % mod) - ((k2 - 1) * k2) / 2) % mod) % mod + mod) % mod << endl;
}
return 0;
}