Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define int long long
- #define fastio ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
- //const long long INF64 = 1'000'000'000'000'000'000ll;
- #define MOD 1000000007
- double pow(double a, int n){
- double ret =1;
- while(n){
- if(n%2==1)ret*=a;
- a*=a;
- n/=2;
- }
- return ret;
- }
- const int MAX_SIZE = 1000009;
- vector<int >isprime(MAX_SIZE , true);
- vector<int >prime;
- vector<int >SPF(MAX_SIZE);
- void manipulated_seive(int N)
- {
- isprime[0] = isprime[1] = false ;
- for (int i=2; i<N ; i++)
- {
- if (isprime[i])
- {
- prime.push_back(i);
- SPF[i] = i;
- }
- for (int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i];j++)
- {
- isprime[i*prime[j]]=false;
- SPF[i*prime[j]] = prime[j] ;
- }
- }
- }
- int gcd(int a,int b){
- if(a==0){
- return b;
- }
- return gcd(b%a,a);
- }
- #undef int
- int main() {
- #define int long long
- //fastio;
- manipulated_seive(1000001);
- int n,m;
- cin>>n>>m;
- //manipulated_seive(1000000);
- int count=1;
- int a=gcd(n,m);
- for(int i=0;i<prime.size();i++){
- if(a%prime[i]==(int)0){
- count++;
- //cout<<prime[i]<<" ";
- }
- }
- {
- cout<<count;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment