Sol
增加了数据组数T<=10000
推到
\\(ans=\\sum_{d=1}^{N}d*\\sum_{i=1}^{\\lfloor\\frac{N}{d}\\rfloor}\\mu(i)*i^2*\\frac{(\\lfloor\\frac{N}{d*i}\\rfloor + 1) * \\lfloor\\frac{N}{d*i}\\rfloor}{2}*\\frac{(\\lfloor\\frac{M}{d*i}\\rfloor + 1) * \\lfloor\\frac{M}{d*i}\\rfloor}{2}\\)
\\(设S(i)=\\frac{(i+1)*i}{2},将d*i换成k\\)
\\(原式=\\sum_{k=1}^{N}S(\\lfloor\\frac{N}{k}\\rfloor)*S(\\lfloor\\frac{M}{k}\\rfloor)*k*\\sum_{i|k}i*\\mu(i)\\)
\\(设f(n)=\\sum_{i|n}i*\\mu(i),它是个积性函数,可以线性筛\\)
# include <bits/stdc++.h>
# define RG register
# define IL inline
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int _(1e7 + 1), MOD(1e8 + 9);
IL ll Read(){
char c = \'%\'; ll x = 0, z = 1;
for(; c > \'9\' || c < \'0\'; c = getchar()) if(c == \'-\') z = -1;
for(; c >= \'0\' && c <= \'9\'; c = getchar()) x = x * 10 + c - \'0\';
return x * z;
}
int prime[_], f[_], num, s[_];
bool isprime[_];
IL void Prepare(){
isprime[1] = 1; s[1] = f[1] = 1;
for(RG int i = 2; i < _; ++i){
if(!isprime[i]) prime[++num] = i, f[i] = 1 - i;
for(RG int j = 1; j <= num && i * prime[j] < _; ++j){
isprime[i * prime[j]] = 1;
if(i % prime[j]) f[i * prime[j]] = 1LL * f[i] * f[prime[j]] % MOD;
else{ f[i * prime[j]] = f[i]; break; }
}
s[i] = (s[i - 1] + 1LL * i * f[i] % MOD) % MOD;
}
}
IL ll S(RG ll x){ return x * (x + 1) / 2 % MOD; }
int main(RG int argc, RG char *argv[]){
Prepare();
for(RG ll T = Read(), n, m; T; --T){
RG ll ans = 0; n = Read(); m = Read();
if(n > m) swap(n, m);
for(RG ll i = 1, j; i <= n; i = j + 1){
j = min(n / (n / i), m / (m / i));
(ans += 1LL * (s[j] - s[i - 1] + MOD) % MOD * S(n / i) % MOD * S(m / i) % MOD) %= MOD;
}
printf("%lld\\n", (ans + MOD) % MOD);
}
return 0;
}