View Code of Problem 102

#include <stdio.h>
int main(){
	int x,y;
	while(scanf("%d %d",&x,&y)!=EOF){
		int p,q,count=0,n,m;     // n是最大公约数  m是最小公倍数 
		for(p=x;p<=y;p++){
			for(q=x;q<=y;q++){
				for(n=p;n>=1;n--){
					if(p%n==0&&q%n==0) break;
				}
				for(m=q;;m++){
					if(m%p==0&&m%q==0) break;
				}
				if(n==x&&m==y) count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 102