湘潭大学oj1218

#include
#include
#include
#include
using namespace std;
#define N 100000
int prime[N];
int elem[N];
int elem_num;
int main()
{
    int t,n,num,cnt,i,flag,ct,a,b,j;
    memset(prime,1,sizeof(prime));
    for(i=2;i<=N;i++)
    {
        for(j=2;j*i         {
            prime[i*j]=0;
        }
    }
    elem_num=0;
    for(i=2;i         if(prime[i])
            elem[elem_num++]=i;
    }
    cin>>t;
    ct=0;
    while(t--){
        cin>>a>>b;
        n=a+b;
        cnt=1;
        flag=(int)sqrt(double(n))+1;
        for(i=0;i             if(elem[i]>flag)break;
            num=0;
            while(n%elem[i]==0){
                n/=elem[i];
                num++;
            }
            cnt*=num+1;
        }
        if(n>1)cnt*=2;
        cout<     }
    return 0;
}

你可能感兴趣的:(湘潭大学oj1218)