Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define endl '\n'
- #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- #define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
- typedef long long int ll;
- const int mx=1e6+123;
- bitset<mx> is_prime;
- vector<ll>v;
- void prime_gen(ll n)
- {
- is_prime[2]=1;
- for(ll i=3;i<=n;i+=2)
- {
- is_prime[i]=1;
- }
- for(ll i=3;i*i<=n;i+=2)
- {
- if(is_prime[i]==1)
- {
- for(ll j=i*i;j<=n;j+=2*i)
- {
- is_prime[j]=0;
- }
- }
- }
- v.push_back(2);
- for(int i=3;i<=n;i+=2)
- {
- if(is_prime[i]==1) v.push_back(i);
- }
- }
- void prime_div(ll n)
- {
- ll ans=1;
- for(auto u:v)
- {
- if(u*u>n) break;
- if(n%u==0)
- {
- int cnt=0;
- while(n%u==0)
- {
- cnt++;
- n/=u;
- }
- ans*=(cnt+1);
- }
- }
- if(n>1) ans*=2;
- cout<<ans;
- }
- int main()
- {
- optimize();
- prime_gen(1e6);
- ll t;
- cin>>t;
- while(t--)
- {
- ll a,b;
- cin>>a>>b;
- prime_div(__gcd ( a, b ));
- cout<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement