CodeChef SHGAME

#include <bits/stdc++.h>
#define int long long

using namespace std;

int tong1[2323233], tong2[2323233];

signed main()
{
  int T;
  cin >> T;
  while (T --)
  {
    int n, m;
    cin >> n >> m;
    n --;
    m --;
    memset (tong1, 0, sizeof tong1);
    memset (tong2, 0, sizeof tong2);
    for (int i = 0; i <= n; i ++)
      tong1[i ^ (n - i)] ++;
    for (int i = 0; i <= m; i ++)
      tong2[i ^ (m - i)] ++;
    int res = (n + 1) * (m + 1);
    for (int i = 0; i <= 1e6; i ++)
      res -= tong1[i] * tong2[i];
    cout << res << '\n';
  }
  return 0;
}

posted @ 2022-10-25 09:38  yhbqwq  阅读(7)  评论(0编辑  收藏  举报