Skip to content

Instantly share code, notes, and snippets.

@nafis00141
Created October 31, 2016 03:20
#include<bits/stdc++.h>
using namespace std;
int countDivisor(int n) { //time complexity O(sqrt(n))
int divisor = 0;
for (int i = 1; i * i <= n; i++) {
if (i * i == n) {
divisor += 1;
}
else if (n % i == 0) {
divisor += 2;
}
}
return divisor;
}
int main(){
int t;
int a,b;
scanf("%d",&t);
while(t--){
scanf("%d %d",&a,&b);
int n = __gcd(a,b);
printf("%d\n",countDivisor(n));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment