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()) {
			long x = scanner.nextLong();
			long y = scanner.nextLong();
			long cheng = x*y;
			long count = 0;
			long s=(long)Math.sqrt(cheng);
			for(long i=x; i<=s; i++) {
				if((cheng % i == 0) && yinshu(i,cheng / i) == x) {
					count += 2;
				}
			}
			if(x == y) {
				count = 1;
			}
			System.out.println(count);
		}
	}
 
	public  static long yinshu(long a, long b) {
		// TODO Auto-generated method stub
		long 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