View Code of Problem 102

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();
			if(x == y) {
				System.out.println(1);
			}
			else {
				int cheng = x*y;
				int count = 0;
				int s=(int)Math.sqrt(cheng);
				for(int i=x; i<=s; 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.


Back to problem 102