fork download
  1. /*
  2. * Author: Geeza
  3.  */
  4.  
  5. #include <bits/stdc++.h>
  6.  
  7. #define ld long double
  8. #define ll long long
  9. #define pb push_back
  10. #define fin(a, n) for(int i = a; i < n; i++)
  11. #define fjn(a, n) for(int j = a; j < n; j++)
  12. #define all(a) a.begin(),a.end()
  13. #define allr(a) a.rbegin(),a.rend()
  14. #define FAST ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
  15.  
  16. using namespace std;
  17.  
  18. const double PI = acos(-1);
  19. const int N = 4e3+20;
  20. const ll oo = 0x3f3f3f3f3f3f3f3f;
  21. const int MOD = 1000000007, inf = 1e9;
  22.  
  23. string di[] = {"D","L", "U", "R", "UL", "UR", "DL", "DR"};
  24. int dx[] = {+1, +0, +0, -1, -1, -1, +1, +1};
  25. int dy[] = {+0, -1, +1, +0, -1, +1, -1, +1};
  26. char dc[] = {'D', 'L', 'R', 'U'};
  27.  
  28. ll mul(ll a, ll b) {
  29. return ((a % MOD) * (b % MOD)) % MOD;
  30. }
  31.  
  32. void solve() {
  33. ll n, k; cin >> n >> k;
  34. n += 2, k += 1;
  35. ll pairs = n * (n-1)/2;
  36. cout << mul(pairs, k) << "\n";
  37. }
  38.  
  39. int main() {
  40. FAST;
  41. #ifndef ONLINE_JUDGE
  42. freopen("input.txt", "r", stdin);
  43. freopen("output.txt", "w", stdout);
  44. #endif
  45. int tt = 1; cin >> tt;
  46. while (tt--) {
  47. solve();
  48. //cout << "Case #" << c++ << ": ";
  49. }
  50. return 0;
  51. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
227630261