Skip to content

Instantly share code, notes, and snippets.

@Shravan40
Last active December 21, 2015 13:09
Show Gist options
  • Save Shravan40/6310446 to your computer and use it in GitHub Desktop.
Save Shravan40/6310446 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<cmath>
using namespace std;
int gcd(int u, int v)
{
while ( v != 0)
{
int r = u % v;
u = v;
v = r;
}
return u;
}
void common_divisor(int p)
{
int numDiv= 1 ;
//temp=0;temp = sqrt(p)+1;
for (int i = 2; i <= p; i++)
{
int exponent = 0;
while (p % i == 0)
{
exponent++;
p /= i;
}
numDiv *= (exponent+1);
}
cout << numDiv<<"\n";
return ;
}
int main()
{
ios_base::sync_with_stdio(false);
int t;
cin>>t;
while(t--)
{
int a,b;
cin>>a >>b;
int c= gcd( a, b);
common_divisor(c);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment