Spoj COMDIV - Number of common divisors Solution
Problem Link:https://www.spoj.com/problems/COMDIV/
Solution in C++:
- ///La ilaha illellahu muhammadur rasulullah
- ///******Bismillahir-Rahmanir-Rahim******///
- ///Abul Hasnat Tonmoy
- ///Department of CSE,23rd batch
- ///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- using namespace std;
- int gcd(long long a, long long b)
- {
- if (a == 0)
- return b;
- return gcd(b % a, a);
- }
- int main()
- {
- ios::sync_with_stdio(false);
- long long t,n,i,divisor,a,b;
- while(t--)
- {
- n=gcd(a,b);
- divisor=0;
- {
- if(i*i==n)
- divisor++;
- else if(n%i==0)
- divisor=divisor+2;
- }
- }
- }
No comments