Last active
December 21, 2015 13:09
-
-
Save Shravan40/6310446 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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