[bzoj2693]jzptab

 

 1 #include<bits/stdc++.h> 
 2 using namespace std;
 3 #define ll long long
 4 #define mod 100000009
 5 #define N 10000005
 6 ll t,n,m,ans,c[N],f[N],vis[N],p[N];
 7 int main(){
 8     scanf("%lld",&t);
 9     f[1]=c[1]=1;
10     for(int i=2;i<=N-5;i++){
11         c[i]=1LL*i*(i+1)/2%mod;
12         if (!vis[i])f[p[++p[0]]=i]=(1LL-i)*i%mod+mod;
13         for(int j=1;j<=p[0];j++){
14             if (i*p[j]>N-5)break;
15             vis[i*p[j]]=1;
16             if (i%p[j])f[i*p[j]]=f[i]*f[p[j]]%mod;
17             else{
18                 f[i*p[j]]=f[i]*p[j]%mod;
19                 break;
20             }
21         }
22     }
23     for(int i=2;i<=N-5;i++)f[i]=(f[i]+f[i-1])%mod;
24     while (t--){
25         scanf("%lld%lld",&n,&m);
26         ans=0;
27         if (n>m)swap(n,m);
28         for(int i=1,j;i<=n;i=j+1){
29             j=min(n/(n/i),m/(m/i));
30             ans=(ans+c[n/i]*c[m/i]%mod*(f[j]-f[i-1]+mod))%mod;
31         }
32         printf("%lld\n",ans);
33     }
34 }
View Code

 

posted @ 2019-07-28 10:39  PYWBKTDA  阅读(103)  评论(0编辑  收藏  举报