Codevs 4712 GCD and LCM problems

Source: Internet
Author: User

This is a year noip what problem of the reinforced version.

And no eggs? The number of linear sieve quality factors can be. Then the answer is 2^ (the number of m/d)

#include <iostream>
#include <cstdio>
#include <cstring>
#define MAXN 1000005
using namespace Std;
int t,m,d;
Int prime[maxn/10],cnt=0,tab[maxn],r[50];
BOOL VIS[MAXN];
void Get_table ()
{
Tab[1]=1;
memset (vis,false,sizeof (VIS));
for (int i=2;i<maxn;i++)
{
if (vis[i]==false)
{
prime[++cnt]=i;
tab[i]=2;
}
for (int j=1;j<=cnt && i*prime[j]<maxn;j++)
{
Vis[i*prime[j]]=true;
if (i%prime[j]==0)
{
Tab[i*prime[j]]=tab[i];
Break
}
Else
tab[i*prime[j]]=tab[i]+1;
}
}
int ans=1;
for (int i=1;i<=35;i++)
{
ans=ans*2;
R[i]=ans;
}
}
int main ()
{
scanf ("%d", &t);
Get_table ();
for (int k=1;k<=t;k++)
{
scanf ("%d%d", &d,&m);
if ((d==0) | | | (m==0)) printf ("0\n");
Else if (m<d) printf ("0\n");
Else if (m%d!=0) printf ("0\n");
Else printf ("%d\n", r[tab[m/d]-1]);
}
return 0;
}

Codevs 4712 GCD and LCM issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.