import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { int x = scanner.nextInt(); int y = scanner.nextInt(); int cheng = x*y; int count = 0; for(int i=x; i<=Math.sqrt(cheng); i++) { if((cheng % i == 0) && yinshu(cheng/i,i) == x) { count ++; } } count *= 2; System.out.println(count); } } public static int yinshu(int a, int b) { // TODO Auto-generated method stub int c = a % b; while(c != 0) { a = b; b = c; c = a % b; } return b; } } |
Double click to view unformatted code.