Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- class totalmultiples2
- {
- public static void main(String args[])throws IOException
- {
- try
- {
- Scanner sc=new Scanner(System.in);
- long a=sc.nextLong();
- long b=sc.nextLong();
- int counter=0;
- long max=a<b?a:b;
- long sqr=a<b?(long)Math.sqrt(a):(long)Math.sqrt(b);
- for(long x=1;x<=sqr;x++)
- {
- if(max%x==0)
- {
- if(x==1)
- counter+=1;
- else
- {
- if(a%x==0&&b%x==0)
- counter+=1;
- long sec=a/x;
- if(a%sec==0&&b%sec==0)
- counter+=1;
- }
- }
- }
- System.out.println(counter);
- }
- catch(Exception e)
- {
- System.out.println("ERROR");
- }
- }
- }
Add Comment
Please, Sign In to add comment